Load missing included chats for filter
Display dialog with unread mention in unmuted filter
This commit is contained in:
parent
ca8f106604
commit
8b04630124
@ -2193,7 +2193,9 @@ export default class ChatBubbles {
|
|||||||
const queue = this.messagesQueue.slice();
|
const queue = this.messagesQueue.slice();
|
||||||
this.messagesQueue.length = 0;
|
this.messagesQueue.length = 0;
|
||||||
|
|
||||||
const promises = queue.reduce((acc, {promises}) => acc.concat(promises), []);
|
const promises = queue.reduce((acc, {promises}) => (acc.push(...promises), acc), []);
|
||||||
|
|
||||||
|
// promises.push(pause(200));
|
||||||
|
|
||||||
// * это нужно для того, чтобы если захочет подгрузить reply или какое-либо сообщение, то скролл не прервался
|
// * это нужно для того, чтобы если захочет подгрузить reply или какое-либо сообщение, то скролл не прервался
|
||||||
// * если добавить этот промис - в таком случае нужно сделать, чтобы скроллило к последнему сообщению после рендера
|
// * если добавить этот промис - в таком случае нужно сделать, чтобы скроллило к последнему сообщению после рендера
|
||||||
|
@ -224,7 +224,14 @@ export default class AppEditFolderTab extends SliderSuperTab {
|
|||||||
this.editCheckForChange();
|
this.editCheckForChange();
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.loadAnimationPromise = lottieLoader.loadAnimationAsAsset({
|
const reloadMissingPromises: Promise<any>[] = this.type === 'edit' ? [
|
||||||
|
appMessagesManager.filtersStorage.reloadMissingPeerIds(this.filter.id, 'pinned_peers'),
|
||||||
|
appMessagesManager.filtersStorage.reloadMissingPeerIds(this.filter.id, 'include_peers'),
|
||||||
|
appMessagesManager.filtersStorage.reloadMissingPeerIds(this.filter.id, 'exclude_peers')
|
||||||
|
] : [];
|
||||||
|
|
||||||
|
return Promise.all([
|
||||||
|
this.loadAnimationPromise = lottieLoader.loadAnimationAsAsset({
|
||||||
container: this.stickerContainer,
|
container: this.stickerContainer,
|
||||||
loop: false,
|
loop: false,
|
||||||
autoplay: false,
|
autoplay: false,
|
||||||
@ -234,7 +241,10 @@ export default class AppEditFolderTab extends SliderSuperTab {
|
|||||||
this.animation = player;
|
this.animation = player;
|
||||||
|
|
||||||
return lottieLoader.waitForFirstFrame(player);
|
return lottieLoader.waitForFirstFrame(player);
|
||||||
});
|
}),
|
||||||
|
|
||||||
|
...reloadMissingPromises
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpenAfterTimeout() {
|
onOpenAfterTimeout() {
|
||||||
@ -327,8 +337,10 @@ export default class AppEditFolderTab extends SliderSuperTab {
|
|||||||
};
|
};
|
||||||
|
|
||||||
setFilter(filter: DialogFilter, firstTime: boolean) {
|
setFilter(filter: DialogFilter, firstTime: boolean) {
|
||||||
|
if(this.container) {
|
||||||
// cleanup
|
// cleanup
|
||||||
Array.from(this.container.querySelectorAll('ul, .load-more')).forEach(el => el.remove());
|
Array.from(this.container.querySelectorAll('ul, .load-more')).forEach(el => el.remove());
|
||||||
|
}
|
||||||
|
|
||||||
if(firstTime) {
|
if(firstTime) {
|
||||||
this.originalFilter = filter;
|
this.originalFilter = filter;
|
||||||
@ -341,8 +353,6 @@ export default class AppEditFolderTab extends SliderSuperTab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public open(filter?: DialogFilter) {
|
public open(filter?: DialogFilter) {
|
||||||
const ret = super.open();
|
|
||||||
|
|
||||||
if(filter === undefined) {
|
if(filter === undefined) {
|
||||||
this.setFilter({
|
this.setFilter({
|
||||||
_: 'dialogFilter',
|
_: 'dialogFilter',
|
||||||
@ -361,9 +371,11 @@ export default class AppEditFolderTab extends SliderSuperTab {
|
|||||||
} else {
|
} else {
|
||||||
this.setFilter(filter, true);
|
this.setFilter(filter, true);
|
||||||
this.type = 'edit';
|
this.type = 'edit';
|
||||||
this.onEditOpen();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return super.open().then(() => {
|
||||||
|
if(this.type === 'edit') this.onEditOpen();
|
||||||
|
else this.onCreateOpen();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ export default class SliderSuperTab implements SliderTab {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.slider.selectTab(this);
|
this.slider.selectTab(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected init(): Promise<any> | any {
|
protected init(): Promise<any> | any {
|
||||||
|
@ -2733,9 +2733,9 @@ export class AppMessagesManager {
|
|||||||
public wrapMessageForReply(message: MyMessage | MyDraftMessage, text: string, usingMids: number[], plain: true, highlightWord?: string, withoutMediaType?: boolean): string;
|
public wrapMessageForReply(message: MyMessage | MyDraftMessage, text: string, usingMids: number[], plain: true, highlightWord?: string, withoutMediaType?: boolean): string;
|
||||||
public wrapMessageForReply(message: MyMessage | MyDraftMessage, text?: string, usingMids?: number[], plain?: false, highlightWord?: string, withoutMediaType?: boolean): DocumentFragment;
|
public wrapMessageForReply(message: MyMessage | MyDraftMessage, text?: string, usingMids?: number[], plain?: false, highlightWord?: string, withoutMediaType?: boolean): DocumentFragment;
|
||||||
public wrapMessageForReply(message: MyMessage | MyDraftMessage, text: string = (message as Message.message).message, usingMids?: number[], plain?: boolean, highlightWord?: string, withoutMediaType?: boolean): DocumentFragment | string {
|
public wrapMessageForReply(message: MyMessage | MyDraftMessage, text: string = (message as Message.message).message, usingMids?: number[], plain?: boolean, highlightWord?: string, withoutMediaType?: boolean): DocumentFragment | string {
|
||||||
const parts: (HTMLElement | string)[] = [];
|
const parts: (Node | string)[] = [];
|
||||||
|
|
||||||
const addPart = (langKey: LangPackKey, part?: string | HTMLElement, text?: string) => {
|
const addPart = (langKey: LangPackKey, part?: string | HTMLElement) => {
|
||||||
if(langKey) {
|
if(langKey) {
|
||||||
part = plain ? I18n.format(langKey, true) : i18n(langKey);
|
part = plain ? I18n.format(langKey, true) : i18n(langKey);
|
||||||
}
|
}
|
||||||
@ -2748,10 +2748,6 @@ export class AppMessagesManager {
|
|||||||
else el.append(part);
|
else el.append(part);
|
||||||
parts.push(el);
|
parts.push(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(text) {
|
|
||||||
parts.push(', ');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if((message as Message.message).media) {
|
if((message as Message.message).media) {
|
||||||
@ -2776,7 +2772,7 @@ export class AppMessagesManager {
|
|||||||
text = this.getAlbumText(message.grouped_id).message;
|
text = this.getAlbumText(message.grouped_id).message;
|
||||||
|
|
||||||
if(!withoutMediaType) {
|
if(!withoutMediaType) {
|
||||||
addPart('AttachAlbum', undefined, text);
|
addPart('AttachAlbum');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2787,15 +2783,14 @@ export class AppMessagesManager {
|
|||||||
const media = message.media;
|
const media = message.media;
|
||||||
switch(media._) {
|
switch(media._) {
|
||||||
case 'messageMediaPhoto':
|
case 'messageMediaPhoto':
|
||||||
addPart('AttachPhoto', undefined, message.message);
|
addPart('AttachPhoto');
|
||||||
break;
|
break;
|
||||||
case 'messageMediaDice':
|
case 'messageMediaDice':
|
||||||
addPart(undefined, plain ? media.emoticon : RichTextProcessor.wrapEmojiText(media.emoticon));
|
addPart(undefined, plain ? media.emoticon : RichTextProcessor.wrapEmojiText(media.emoticon));
|
||||||
break;
|
break;
|
||||||
case 'messageMediaVenue': {
|
case 'messageMediaVenue': {
|
||||||
const text = plain ? media.title : RichTextProcessor.wrapEmojiText(media.title);
|
text = media.title;
|
||||||
addPart('AttachLocation', undefined, text);
|
addPart('AttachLocation');
|
||||||
parts.push(htmlToDocumentFragment(text) as any);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'messageMediaGeo':
|
case 'messageMediaGeo':
|
||||||
@ -2812,20 +2807,20 @@ export class AppMessagesManager {
|
|||||||
break;
|
break;
|
||||||
case 'messageMediaGame': {
|
case 'messageMediaGame': {
|
||||||
const prefix = '🎮' + ' ';
|
const prefix = '🎮' + ' ';
|
||||||
addPart(undefined, plain ? prefix + media.game.title : RichTextProcessor.wrapEmojiText(prefix + media.game.title));
|
text = prefix + media.game.title;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'messageMediaDocument': {
|
case 'messageMediaDocument': {
|
||||||
const document = media.document as MyDocument;
|
const document = media.document as MyDocument;
|
||||||
|
|
||||||
if(document.type === 'video') {
|
if(document.type === 'video') {
|
||||||
addPart('AttachVideo', undefined, message.message);
|
addPart('AttachVideo');
|
||||||
} else if(document.type === 'voice') {
|
} else if(document.type === 'voice') {
|
||||||
addPart('AttachAudio', undefined, message.message);
|
addPart('AttachAudio');
|
||||||
} else if(document.type === 'gif') {
|
} else if(document.type === 'gif') {
|
||||||
addPart('AttachGif', undefined, message.message);
|
addPart('AttachGif');
|
||||||
} else if(document.type === 'round') {
|
} else if(document.type === 'round') {
|
||||||
addPart('AttachRound', undefined, message.message);
|
addPart('AttachRound');
|
||||||
} else if(document.type === 'sticker') {
|
} else if(document.type === 'sticker') {
|
||||||
if(document.stickerEmojiRaw) {
|
if(document.stickerEmojiRaw) {
|
||||||
addPart(undefined, (plain ? document.stickerEmojiRaw : document.stickerEmoji) + ' ');
|
addPart(undefined, (plain ? document.stickerEmojiRaw : document.stickerEmoji) + ' ');
|
||||||
@ -2836,9 +2831,9 @@ export class AppMessagesManager {
|
|||||||
} else if(document.type === 'audio') {
|
} else if(document.type === 'audio') {
|
||||||
const attribute = document.attributes.find(attribute => attribute._ === 'documentAttributeAudio' && (attribute.title || attribute.performer)) as DocumentAttribute.documentAttributeAudio;
|
const attribute = document.attributes.find(attribute => attribute._ === 'documentAttributeAudio' && (attribute.title || attribute.performer)) as DocumentAttribute.documentAttributeAudio;
|
||||||
const f = '🎵' + ' ' + (attribute ? [attribute.title, attribute.performer].filter(Boolean).join(' - ') : document.file_name);
|
const f = '🎵' + ' ' + (attribute ? [attribute.title, attribute.performer].filter(Boolean).join(' - ') : document.file_name);
|
||||||
addPart(undefined, plain ? f : RichTextProcessor.wrapEmojiText(f), message.message);
|
addPart(undefined, plain ? f : RichTextProcessor.wrapEmojiText(f));
|
||||||
} else {
|
} else {
|
||||||
addPart(undefined, plain ? document.file_name : RichTextProcessor.wrapEmojiText(document.file_name), message.message);
|
addPart(undefined, plain ? document.file_name : RichTextProcessor.wrapEmojiText(document.file_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -2850,6 +2845,10 @@ export class AppMessagesManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(text && parts.length) {
|
||||||
|
parts.push(', ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((message as Message.messageService).action) {
|
if((message as Message.messageService).action) {
|
||||||
|
@ -49,7 +49,7 @@ export default class FiltersStorage {
|
|||||||
private apiUpdatesManager: ApiUpdatesManager,
|
private apiUpdatesManager: ApiUpdatesManager,
|
||||||
/* private apiManager: ApiManagerProxy, */
|
/* private apiManager: ApiManagerProxy, */
|
||||||
private rootScope: typeof _rootScope) {
|
private rootScope: typeof _rootScope) {
|
||||||
this.clear();
|
this.clear(true);
|
||||||
this.filters = {};
|
this.filters = {};
|
||||||
|
|
||||||
this.appStateManager.getState().then((state) => {
|
this.appStateManager.getState().then((state) => {
|
||||||
@ -114,10 +114,13 @@ export default class FiltersStorage {
|
|||||||
public clear(init = false) {
|
public clear(init = false) {
|
||||||
if(!init) {
|
if(!init) {
|
||||||
safeReplaceObject(this.filters, {});
|
safeReplaceObject(this.filters, {});
|
||||||
|
this.reloadedPeerIds.clear();
|
||||||
|
} else {
|
||||||
|
this.filters = {};
|
||||||
|
this.reloadedPeerIds = new Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.orderIndex = START_ORDER_INDEX;
|
this.orderIndex = START_ORDER_INDEX;
|
||||||
this.reloadedPeerIds = new Set();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private onUpdateDialogFilter = (update: Update.updateDialogFilter) => {
|
private onUpdateDialogFilter = (update: Update.updateDialogFilter) => {
|
||||||
@ -178,12 +181,9 @@ export default class FiltersStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// exclude_muted
|
// exclude_muted
|
||||||
if(pFlags.exclude_muted) {
|
if(pFlags.exclude_muted && this.appNotificationsManager.isPeerLocalMuted(peerId) && !(dialog.unread_mentions_count && dialog.unread_count)) {
|
||||||
const isMuted = this.appNotificationsManager.isPeerLocalMuted(peerId);
|
|
||||||
if(isMuted) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(this.appPeersManager.isAnyChat(peerId)) {
|
if(this.appPeersManager.isAnyChat(peerId)) {
|
||||||
// broadcasts
|
// broadcasts
|
||||||
@ -320,12 +320,12 @@ export default class FiltersStorage {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public reloadMissingPeerIds(filterId: number) {
|
public reloadMissingPeerIds(filterId: number, type: 'pinned_peers' | 'include_peers' | 'exclude_peers' = 'pinned_peers') {
|
||||||
const promises: Promise<any>[] = [];
|
const promises: Promise<any>[] = [];
|
||||||
const filter = this.getFilter(filterId);
|
const filter = this.getFilter(filterId);
|
||||||
const pinnedPeers = filter?.pinned_peers;
|
const peers = filter && filter[type];
|
||||||
if(pinnedPeers?.length) {
|
if(peers?.length) {
|
||||||
const reloadDialogs = pinnedPeers.filter((inputPeer, idx) => {
|
const reloadDialogs = peers.filter((inputPeer, idx) => {
|
||||||
const peerId = this.appPeersManager.getPeerId(inputPeer);
|
const peerId = this.appPeersManager.getPeerId(inputPeer);
|
||||||
return !this.reloadedPeerIds.has(peerId) && !this.appMessagesManager.getDialogOnly(peerId);
|
return !this.reloadedPeerIds.has(peerId) && !this.appMessagesManager.getDialogOnly(peerId);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user