Browse Source

Shared media fixes:

Fix load end of document tab
Add support for entity-check in links tab
master
morethanwords 4 years ago
parent
commit
d60910f533
  1. 16
      src/components/sidebarRight/tabs/sharedMedia.ts
  2. 17
      src/lib/appManagers/appMessagesManager.ts
  3. 7
      src/scss/partials/_chatBubble.scss

16
src/components/sidebarRight/tabs/sharedMedia.ts

@ -648,7 +648,7 @@ export default class AppSharedMediaTab implements SliderTab { @@ -648,7 +648,7 @@ export default class AppSharedMediaTab implements SliderTab {
if(!typesToLoad.length) return;
const loadCount = justLoad ? 50 : (appPhotosManager.windowH / 130 | 0) * 3 * 1.25; // that's good for all types
const loadCount = justLoad ? 50 : Math.round((appPhotosManager.windowH / 130 | 0) * 3 * 1.25); // that's good for all types
const historyStorage = this.historiesStorage[peerID] ?? (this.historiesStorage[peerID] = {});
@ -657,27 +657,29 @@ export default class AppSharedMediaTab implements SliderTab { @@ -657,27 +657,29 @@ export default class AppSharedMediaTab implements SliderTab {
const history = historyStorage[type] ?? (historyStorage[type] = []);
const logStr = `loadSidebarMedia [${type}]: `;
const logStr = 'loadSidebarMedia [' + type + ']: ';
// render from cache
if(history.length && this.usedFromHistory[type] < history.length && !justLoad) {
let messages: any[] = [];
let used = Math.max(0, this.usedFromHistory[type]);
let slicedLength = 0;
do {
let ids = history.slice(used, used + loadCount);
this.log(logStr + 'will render from cache', used, history, ids, loadCount);
used += ids.length;
slicedLength += ids.length;
messages.push(...this.filterMessagesByType(ids, type));
} while(messages.length < loadCount && used < history.length);
} while(slicedLength < loadCount && used < history.length);
// если перебор
if(messages.length > loadCount) {
/* if(slicedLength > loadCount) {
let diff = messages.length - loadCount;
messages = messages.slice(0, messages.length - diff);
used -= diff;
}
} */
this.usedFromHistory[type] = used;
//if(messages.length) {
@ -704,7 +706,9 @@ export default class AppSharedMediaTab implements SliderTab { @@ -704,7 +706,9 @@ export default class AppSharedMediaTab implements SliderTab {
return;
}
if(history.length >= value.count) {
// ! Фикс случая, когда не загружаются документы при открытой панели разработчиков (происходит из-за того, что не совпадают критерии отбора документов в getSearch)
if(value.history.length < loadCount) {
//if((value.count || history.length == value.count) && history.length >= value.count) {
this.log(logStr + 'loaded all media', value, loadCount);
this.loadedAllMedia[type] = true;
}

17
src/lib/appManagers/appMessagesManager.ts

@ -3039,7 +3039,7 @@ export class AppMessagesManager { @@ -3039,7 +3039,7 @@ export class AppMessagesManager {
var neededContents: {
[messageMediaType: string]: boolean
} = {},
neededDocTypes: string[] = [];
neededDocTypes: string[] = [], excludeDocTypes: string[] = [];
switch(inputFilter._) {
case 'inputMessagesFilterPhotos':
@ -3059,6 +3059,7 @@ export class AppMessagesManager { @@ -3059,6 +3059,7 @@ export class AppMessagesManager {
case 'inputMessagesFilterDocument':
neededContents['messageMediaDocument'] = true;
excludeDocTypes.push('video');
break;
case 'inputMessagesFilterVoice':
@ -3107,16 +3108,20 @@ export class AppMessagesManager { @@ -3107,16 +3108,20 @@ export class AppMessagesManager {
//|| (neededContents['mentioned'] && message.totalEntities.find((e: any) => e._ == 'messageEntityMention'));
let found = false;
if(message.media && neededContents[message.media._]) {
if(neededDocTypes.length &&
message.media._ == 'messageMediaDocument' &&
!neededDocTypes.includes(message.media.document.type)) {
if(message.media && neededContents[message.media._] && !message.fwd_from) {
if(message.media._ == 'messageMediaDocument') {
if((neededDocTypes.length && !neededDocTypes.includes(message.media.document.type))
|| excludeDocTypes.includes(message.media.document.type)) {
continue;
}
}
found = true;
} else if(neededContents['url'] && message.message && RichTextProcessor.matchUrl(message.message)) {
} else if(neededContents['url'] && message.message) {
const goodEntities = ['messageEntityTextUrl', 'messageEntityUrl'];
if((message.totalEntities as MessageEntity[]).find(e => goodEntities.includes(e._)) || RichTextProcessor.matchUrl(message.message)) {
found = true;
}
} else if(neededContents['avatar'] && message.action && ['messageActionChannelEditPhoto', 'messageActionChatEditPhoto'].includes(message.action._)) {
found = true;
}

7
src/scss/partials/_chatBubble.scss

@ -1682,6 +1682,7 @@ poll-element { @@ -1682,6 +1682,7 @@ poll-element {
display: block;
//min-width: 280px;
min-width: 330px;
user-select: none;
@include respond-to(handhelds) {
min-width: 240px;
@ -1694,7 +1695,6 @@ poll-element { @@ -1694,7 +1695,6 @@ poll-element {
.poll {
&-title {
font-weight: 500;
user-select: none;
@include respond-to(handhelds) {
max-width: 88%;
@ -1706,7 +1706,6 @@ poll-element { @@ -1706,7 +1706,6 @@ poll-element {
color: #707579;
margin-top: 2px;
margin-bottom: 7px;
user-select: none;
display: flex;
position: relative;
@ -1754,7 +1753,6 @@ poll-element { @@ -1754,7 +1753,6 @@ poll-element {
&-text {
margin-top: 6px;
margin-left: 12px;
user-select: none;
}
&-percents {
@ -1769,7 +1767,6 @@ poll-element { @@ -1769,7 +1767,6 @@ poll-element {
margin-left: -9px;
text-align: right;
width: 40px;
user-select: none;
}
&-selected {
@ -1834,7 +1831,6 @@ poll-element { @@ -1834,7 +1831,6 @@ poll-element {
&-votes-count {
color: #707579;
font-size: 14px;
user-select: none;
padding-top: 1px;
}
@ -1877,7 +1873,6 @@ poll-element { @@ -1877,7 +1873,6 @@ poll-element {
//border-bottom-right-radius: 12px;
font-size: 1rem;
line-height: 37px;
user-select: none;
overflow: hidden;
}

Loading…
Cancel
Save