mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Update conversation.unreadCount in just one place, from database
This commit is contained in:
@@ -4644,10 +4644,16 @@ export class ConversationModel extends window.Backbone
|
||||
}
|
||||
): Promise<void> {
|
||||
await markConversationRead(this.attributes, newestUnreadAt, options);
|
||||
await this.updateUnread();
|
||||
}
|
||||
|
||||
async updateUnread(): Promise<void> {
|
||||
const unreadCount = await window.Signal.Data.getTotalUnreadForConversation(
|
||||
this.id,
|
||||
{ storyId: undefined, isGroup: isGroup(this.attributes) }
|
||||
{
|
||||
storyId: undefined,
|
||||
isGroup: isGroup(this.attributes),
|
||||
}
|
||||
);
|
||||
|
||||
const prevUnreadCount = this.get('unreadCount');
|
||||
|
||||
@@ -2647,6 +2647,8 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||
|
||||
window.Whisper.events.trigger('incrementProgress');
|
||||
confirm();
|
||||
|
||||
conversation.queueJob('updateUnread', () => conversation.updateUnread());
|
||||
}
|
||||
|
||||
// This function is called twice - once from handleDataMessage, and then again from
|
||||
@@ -2776,7 +2778,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||
);
|
||||
} else if (isFirstRun && !isGroupStoryReply) {
|
||||
conversation.set({
|
||||
unreadCount: (conversation.get('unreadCount') || 0) + 1,
|
||||
isArchived: false,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user