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.
pull/749/head
ody 10 years ago committed by lilia
parent 641a7dbc6d
commit 8c59862e3d

@ -172,8 +172,6 @@
type : 'incoming'
});
var newUnreadCount = storage.get("unreadCount", 0) + 1;
storage.put("unreadCount", newUnreadCount);
extension.navigator.setBadgeText(newUnreadCount);
return message;

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

Loading…
Cancel
Save