From 6bbabce8e366ab3bf4b2722878cde726ab30bff0 Mon Sep 17 00:00:00 2001 From: Brice-W Date: Thu, 22 Jul 2021 15:21:52 +1000 Subject: [PATCH] fix async issue --- ts/models/conversation.ts | 2 +- ts/models/message.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 7b879d0a4..10c826805 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -947,7 +947,7 @@ export class ConversationModel extends Backbone.Model { // Build the list of updated message models so we can mark them all as read on a single sqlite call for (const nowRead of oldUnreadNowRead) { - nowRead.markReadNoCommit(options.readAt); + await nowRead.markReadNoCommit(options.readAt); const errors = nowRead.get('errors'); read.push({ diff --git a/ts/models/message.ts b/ts/models/message.ts index c755b8664..f02675f3d 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -1045,20 +1045,20 @@ export class MessageModel extends Backbone.Model { } public async markRead(readAt: number) { - this.markReadNoCommit(readAt); + await this.markReadNoCommit(readAt); this.getConversation()?.markRead(this.attributes.received_at); await this.commit(); } - public markReadNoCommit(readAt: number) { + public async markReadNoCommit(readAt: number) { this.set({ unread: 0 }); if (this.get('expireTimer') && !this.get('expirationStartTimestamp')) { const expirationStartTimestamp = Math.min(Date.now(), readAt || Date.now()); this.set({ expirationStartTimestamp }); - this.setToExpire(false); + await this.setToExpire(false); } window.Whisper.Notifications.remove(