Fix global unread message counting
Fixed the global counting of unread messages. This makes the "unreadCount" variable in storage to stay in sync with the sum of unread messages in each conversation. To achieve this, the controller_view updates the global variable whenever messages are received or read.
This commit is contained in:
@@ -29,11 +29,10 @@
|
||||
},
|
||||
updateUnreadCount: function(model, count) {
|
||||
var prev = model.previous('unreadCount') || 0;
|
||||
if (count < prev) { // decreased
|
||||
var newUnreadCount = storage.get("unreadCount", 0) - (prev - count);
|
||||
setUnreadCount(newUnreadCount);
|
||||
storage.put("unreadCount", newUnreadCount);
|
||||
}
|
||||
var newUnreadCount = storage.get("unreadCount", 0) - (prev - count);
|
||||
setUnreadCount(newUnreadCount);
|
||||
storage.remove("unreadCount");
|
||||
storage.put("unreadCount", newUnreadCount);
|
||||
}
|
||||
}))();
|
||||
|
||||
|
Reference in New Issue
Block a user