Don't let unreadCount become negative

If you had an inaccurate unread count due to previously broken unread
tracking, it's possible to go negative and never fully recover. Fixed
by clamping to zero.

// FREEBIE
pull/749/head
lilia 10 years ago
parent 83298b8979
commit 31b29b67f2

@ -30,6 +30,7 @@
updateUnreadCount: function(model, count) {
var prev = model.previous('unreadCount') || 0;
var newUnreadCount = storage.get("unreadCount", 0) - (prev - count);
if (newUnreadCount < 0) { newUnreadCount = 0; }
storage.remove("unreadCount");
storage.put("unreadCount", newUnreadCount);

Loading…
Cancel
Save