From 89046484eda089364a1dffbc44be7156b762dc36 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 7 Jun 2017 11:24:21 -0700 Subject: [PATCH] Read receipts: Also mark all messages read prior to this one We mark as read everything older than this message - to clean up old stuff still marked unread in the database. If the user generally doesn't read in the desktop app, so the desktop app only gets read receipts, we can very easily end up with messages never marked as read (our previous early read receipt handling, read receipts never sent because app was offline). FREEBIE --- js/models/conversations.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 5a7a8640741c..82f96c61887e 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -66,9 +66,12 @@ this.messageCollection.get(message.id).fetch(); } - return this.getUnread().then(function(unreadMessages) { - this.save({unreadCount: unreadMessages.length}); - }.bind(this)); + // We mark as read everything older than this message - to clean up old stuff + // still marked unread in the database. If the user generally doesn't read in + // the desktop app, so the desktop app only gets read receipts, we can very + // easily end up with messages never marked as read (our previous early read + // receipt handling, read receipts never sent because app was offline) + return this.markRead(message.get('received_at')); }, getUnread: function() {