Update unread count when marking as unread

Co-authored-by: Chris Svenningsen <chris@carbonfive.com>
This commit is contained in:
Sidney Keese 2020-10-30 15:36:51 -07:00 committed by Evan Hahn
parent 8bfaf598af
commit cfc3c123bc
2 changed files with 20 additions and 1 deletions

View file

@ -74,9 +74,27 @@ export function start(): void {
const canCountMutedConversations = window.storage.get(
'badge-count-muted-conversations'
);
const canCount = (m: ConversationModel) =>
!m.isMuted() || canCountMutedConversations;
const getUnreadCount = (m: ConversationModel) => {
const unreadCount = m.get('unreadCount');
if (unreadCount) {
return unreadCount;
}
if (m.get('markedUnread')) {
return 1;
}
return 0;
};
const newUnreadCount = reduce(
this.map((m: ConversationModel) =>
!canCountMutedConversations && m.isMuted() ? 0 : m.get('unreadCount')
canCount(m) ? getUnreadCount(m) : 0
),
(item: number, memo: number) => (item || 0) + memo,
0

View file

@ -3030,6 +3030,7 @@ export class ConversationModel extends window.Backbone.Model<
this.set({ markedUnread });
window.Signal.Data.updateConversation(this.attributes);
this.captureChange('markedUnread');
window.Whisper.events.trigger('updateUnreadCount');
}
async updateExpirationTimer(