Count unread marks as unread in folders

This commit is contained in:
Eduard Kuzmenko 2021-02-02 02:09:24 +02:00
parent 858322c409
commit b27f8ef385
2 changed files with 14 additions and 3 deletions

View File

@ -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 : '';
}

View File

@ -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;