From 83298b8979337c3b7b79a905366cf7a1b644a827 Mon Sep 17 00:00:00 2001 From: OdysseasKr Date: Sat, 14 Nov 2015 13:47:21 +0200 Subject: [PATCH] Mark conversation as read if open and window focused Messages that are received in the active conversation while the window is focused, are automatically marked as read. The conversation appears as unread for a split second as the incoming message arrives but it gets marked as read as soon as the message is displayed. --- js/conversation_controller.js | 3 ++- js/views/conversation_view.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/js/conversation_controller.js b/js/conversation_controller.js index 6633e3689..efed0e96d 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -30,9 +30,10 @@ updateUnreadCount: function(model, count) { var prev = model.previous('unreadCount') || 0; var newUnreadCount = storage.get("unreadCount", 0) - (prev - count); - setUnreadCount(newUnreadCount); storage.remove("unreadCount"); storage.put("unreadCount", newUnreadCount); + + setUnreadCount(newUnreadCount); } }))(); diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index f8dfe7fb3..f9d5c1120 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -109,6 +109,10 @@ addMessage: function(message) { this.model.messageCollection.add(message, {merge: true}); + + if (!this.isHidden() && window.isFocused()) { + this.markRead(); + } }, viewMembers: function() {