Skip to content

Commit

Permalink
Read receipts: Also mark all messages read prior to this one
Browse files Browse the repository at this point in the history
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
  • Loading branch information
scottnonnenberg committed Jun 7, 2017
1 parent f38d8eb commit 8904648
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions js/models/conversations.js
Expand Up @@ -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() {
Expand Down

0 comments on commit 8904648

Please sign in to comment.