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.
This commit is contained in:
OdysseasKr 2015-11-14 13:47:21 +02:00 committed by lilia
parent 86edcc06c2
commit 83298b8979
2 changed files with 6 additions and 1 deletions

View File

@ -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);
}
}))();

View File

@ -109,6 +109,10 @@
addMessage: function(message) {
this.model.messageCollection.add(message, {merge: true});
if (!this.isHidden() && window.isFocused()) {
this.markRead();
}
},
viewMembers: function() {