From bee4efac9033dbc591035f85948239cb9271aa7a Mon Sep 17 00:00:00 2001 From: morethanwords Date: Wed, 10 Nov 2021 04:45:01 +0400 Subject: [PATCH] Possible folders loading fix after clearing dialog --- src/lib/appManagers/appDialogsManager.ts | 6 ++++++ src/lib/storages/dialogs.ts | 6 ++++-- src/lib/storages/filters.ts | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lib/appManagers/appDialogsManager.ts b/src/lib/appManagers/appDialogsManager.ts index 05eccfe1..b35313c7 100644 --- a/src/lib/appManagers/appDialogsManager.ts +++ b/src/lib/appManagers/appDialogsManager.ts @@ -827,6 +827,12 @@ export class AppDialogsManager { }; dialogs.forEach((dialog) => { + // :( + const isBuggedDialog = !appMessagesManager.getDialogOnly(dialog.peerId); + if(isBuggedDialog) { + return; + } + const element = this.sortedList.add(dialog.peerId, true, cccc, false); if(element.loadPromises) { loadPromises.push(...element.loadPromises); diff --git a/src/lib/storages/dialogs.ts b/src/lib/storages/dialogs.ts index ac6574e6..8e19d544 100644 --- a/src/lib/storages/dialogs.ts +++ b/src/lib/storages/dialogs.ts @@ -595,13 +595,15 @@ export default class DialogsStorage { const foundDialog = this.getDialog(peerId, undefined, false); const [dialog, index] = foundDialog; if(dialog) { + delete this.dialogs[peerId]; + const folder = this.getFolder(dialog.folder_id); folder.dialogs.splice(index, 1); + const wasPinned = indexOfAndSplice(this.pinnedOrders[dialog.folder_id], peerId) !== undefined; + this.processDialogForFilters(dialog); - const wasPinned = indexOfAndSplice(this.pinnedOrders[dialog.folder_id], peerId) !== undefined; this.dialogsIndex.indexObject(peerId, ''); - delete this.dialogs[peerId]; if(wasPinned) { this.savePinnedOrders(); diff --git a/src/lib/storages/filters.ts b/src/lib/storages/filters.ts index 06438c0d..1681cb31 100644 --- a/src/lib/storages/filters.ts +++ b/src/lib/storages/filters.ts @@ -128,6 +128,11 @@ export default class FiltersStorage { public testDialogForFilter(dialog: Dialog, filter: MyDialogFilter) { const peerId = dialog.peerId; + // * check whether dialog exists + if(!this.appMessagesManager.getDialogOnly(peerId)) { + return false; + } + // exclude_peers if(filter.excludePeerIds.includes(peerId)) { return false;