Browse Source

Count unread marks as unread in folders

master
Eduard Kuzmenko 4 years ago
parent
commit
b27f8ef385
  1. 14
      src/lib/appManagers/appDialogsManager.ts
  2. 3
      src/lib/appManagers/appMessagesManager.ts

14
src/lib/appManagers/appDialogsManager.ts

@ -540,14 +540,24 @@ export class AppDialogsManager {
}; };
private setFilterUnreadCount(filterId: number, folder?: Dialog[]) { 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) { if(!unreadSpan) {
return; return;
} }
folder = folder || appMessagesManager.dialogsStorage.getFolder(filterId); 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 : ''; unreadSpan.innerText = sum ? '' + sum : '';
} }

3
src/lib/appManagers/appMessagesManager.ts

@ -4266,7 +4266,8 @@ export class AppMessagesManager {
public isDialogMuted(dialog: MTDialog.dialog) { public isDialogMuted(dialog: MTDialog.dialog) {
let muted = false; let muted = false;
if(dialog && dialog.notify_settings && dialog.notify_settings.mute_until) { 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; return muted;

Loading…
Cancel
Save