From 0f4f00ff4ecb4494bc070b486533ca614cbbaabf Mon Sep 17 00:00:00 2001 From: lilia Date: Mon, 4 Apr 2016 16:14:15 -0700 Subject: [PATCH] Fix read sync on duplicate messages In the case of a double send (same message encrypted and sent twice due to key conflict bug), we would mark the first instance read twice rather than marking both instances read. Fix by searching for matching messages that have not yet been marked read. // FREEBIE --- js/background.js | 2 +- js/models/messages.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/js/background.js b/js/background.js index 81fdb0b35..4bce9b6d1 100644 --- a/js/background.js +++ b/js/background.js @@ -253,7 +253,7 @@ var ids = groups.pluck('id'); ids.push(sender); var message = messages.find(function(message) { - return (message.get('type') === 'incoming' && + return (message.isIncoming() && message.isUnread() && _.contains(ids, message.get('conversationId'))); }); if (message) { diff --git a/js/models/messages.js b/js/models/messages.js index e61595e3d..67588a2de 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -35,6 +35,9 @@ isIncoming: function() { return this.get('type') === 'incoming'; }, + isUnread: function() { + return !!this.get('unread'); + }, getDescription: function() { if (this.isGroupUpdate()) { var group_update = this.get('group_update');