diff --git a/src/lib/appManagers/appDialogsManager.ts b/src/lib/appManagers/appDialogsManager.ts index 7d09414c..d6e4181b 100644 --- a/src/lib/appManagers/appDialogsManager.ts +++ b/src/lib/appManagers/appDialogsManager.ts @@ -540,14 +540,24 @@ export class AppDialogsManager { }; private setFilterUnreadCount(filterId: number, folder?: Dialog[]) { - const unreadSpan = filterId == 0 ? this.allUnreadCount : this.filtersRendered[filterId]?.unread; + const unreadSpan = filterId === 0 ? this.allUnreadCount : this.filtersRendered[filterId]?.unread; if(!unreadSpan) { return; } folder = folder || appMessagesManager.dialogsStorage.getFolder(filterId); - const sum = folder.reduce((acc, dialog) => acc + +!!dialog.unread_count, 0); + let mutedCount = 0; + let notMutedCount = 0; + folder.forEach(dialog => { + const isMuted = appMessagesManager.isDialogMuted(dialog); + const value = +!!dialog.unread_count || ((filterId !== 0 || !isMuted) && +dialog.pFlags.unread_mark) || 0; // * unread_mark can be undefined + if(isMuted) mutedCount += value; + else notMutedCount += value; + }); + + unreadSpan.classList.toggle('badge-gray', mutedCount && !notMutedCount); + const sum = mutedCount + notMutedCount; unreadSpan.innerText = sum ? '' + sum : ''; } diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index 938d74de..11adb8b7 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -4266,7 +4266,8 @@ export class AppMessagesManager { public isDialogMuted(dialog: MTDialog.dialog) { let muted = false; if(dialog && dialog.notify_settings && dialog.notify_settings.mute_until) { - muted = new Date(dialog.notify_settings.mute_until * 1000) > new Date(); + //muted = new Date(dialog.notify_settings.mute_until * 1000) > new Date(); + muted = (dialog.notify_settings.mute_until * 1000) > Date.now(); } return muted;