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:
		
					parent
					
						
							
								83298b8979
							
						
					
				
			
			
				commit
				
					
						31b29b67f2
					
				
			
		
					 1 changed files with 1 additions and 0 deletions
				
			
		| 
						 | 
					@ -30,6 +30,7 @@
 | 
				
			||||||
        updateUnreadCount: function(model, count) {
 | 
					        updateUnreadCount: function(model, count) {
 | 
				
			||||||
            var prev = model.previous('unreadCount') || 0;
 | 
					            var prev = model.previous('unreadCount') || 0;
 | 
				
			||||||
            var newUnreadCount = storage.get("unreadCount", 0) - (prev - count);
 | 
					            var newUnreadCount = storage.get("unreadCount", 0) - (prev - count);
 | 
				
			||||||
 | 
					            if (newUnreadCount < 0) { newUnreadCount = 0; }
 | 
				
			||||||
            storage.remove("unreadCount");
 | 
					            storage.remove("unreadCount");
 | 
				
			||||||
            storage.put("unreadCount", newUnreadCount);
 | 
					            storage.put("unreadCount", newUnreadCount);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue