From 31b29b67f2d793619e7430ff83eeffdc53a819d7 Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 19 Nov 2015 10:47:50 -0800 Subject: [PATCH] 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 --- js/conversation_controller.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/conversation_controller.js b/js/conversation_controller.js index efed0e96..e4c5ae63 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -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);