Browse Source

Fix unread mentions count

master
morethanwords 3 years ago
parent
commit
47325b3d48
  1. 2
      src/components/chat/input.ts
  2. 10
      src/lib/appManagers/appMessagesManager.ts

2
src/components/chat/input.ts

@ -859,7 +859,7 @@ export default class ChatInput { @@ -859,7 +859,7 @@ export default class ChatInput {
this.goDownUnreadBadge.classList.toggle('badge-gray', this.appNotificationsManager.isPeerLocalMuted(this.chat.peerId, true));
if(this.goMentionUnreadBadge && this.chat.type === 'chat') {
const hasMentions = !!dialog?.unread_mentions_count;
const hasMentions = !!(dialog?.unread_mentions_count && dialog.unread_count);
this.goMentionUnreadBadge.innerText = hasMentions ? '' + (dialog.unread_mentions_count) : '';
this.goMentionBtn.classList.toggle('is-visible', hasMentions);
}

10
src/lib/appManagers/appMessagesManager.ts

@ -4618,7 +4618,7 @@ export class AppMessagesManager { @@ -4618,7 +4618,7 @@ export class AppMessagesManager {
foundDialog.unread_count = setCount;
}
if(newUnreadMentionsCount < 0) {
if(newUnreadMentionsCount < 0 || !foundDialog.unread_count) {
foundDialog.unread_mentions_count = 0;
}
}
@ -4730,14 +4730,14 @@ export class AppMessagesManager { @@ -4730,14 +4730,14 @@ export class AppMessagesManager {
const affected = historyUpdated.unreadMentions || historyUpdated.unread;
const releaseUnreadCount = affected && this.dialogsStorage.prepareDialogUnreadCountModifying(foundDialog);
if(historyUpdated.unreadMentions) {
foundDialog.unread_mentions_count = Math.max(0, foundDialog.unread_mentions_count - historyUpdated.unreadMentions);
}
if(historyUpdated.unread) {
foundDialog.unread_count = Math.max(0, foundDialog.unread_count - historyUpdated.unread);
}
if(historyUpdated.unreadMentions) {
foundDialog.unread_mentions_count = !foundDialog.unread_count ? 0 : Math.max(0, foundDialog.unread_mentions_count - historyUpdated.unreadMentions);
}
if(affected) {
releaseUnreadCount();
rootScope.dispatchEvent('dialog_unread', {peerId});

Loading…
Cancel
Save