Update unread count when marking as unread
Co-authored-by: Chris Svenningsen <chris@carbonfive.com>
This commit is contained in:
parent
8bfaf598af
commit
cfc3c123bc
2 changed files with 20 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue