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:
parent
641a7dbc6d
commit
8c59862e3d
2 changed files with 4 additions and 7 deletions
|
@ -172,8 +172,6 @@
|
|||
type : 'incoming'
|
||||
});
|
||||
|
||||
var newUnreadCount = storage.get("unreadCount", 0) + 1;
|
||||
storage.put("unreadCount", newUnreadCount);
|
||||
extension.navigator.setBadgeText(newUnreadCount);
|
||||
|
||||
return message;
|
||||
|
|
|
@ -29,12 +29,11 @@
|
|||
},
|
||||
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.remove("unreadCount");
|
||||
storage.put("unreadCount", newUnreadCount);
|
||||
}
|
||||
}
|
||||
}))();
|
||||
|
||||
window.getInboxCollection = function() {
|
||||
|
|
Loading…
Reference in a new issue