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
This commit is contained in:
lilia 2015-11-19 10:47:50 -08:00
parent 83298b8979
commit 31b29b67f2

View file

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