From 4ea457a01cd18ef4f6ebab81e81eb65730e4c5c8 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Thu, 27 Jul 2017 17:31:15 -0700 Subject: [PATCH] Fix second fetchConversation call if unread > 0 FREEBIE --- js/models/messages.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/models/messages.js b/js/models/messages.js index 071327fca..d84f1b4e8 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -597,7 +597,7 @@ }, getLoadedUnreadCount: function() { - return this.models.reduce(function(total, model) { + return this.reduce(function(total, model) { var unread = model.get('unread') && model.isIncoming(); return total + (unread ? 1 : 0); }, 0); @@ -637,11 +637,11 @@ this.fetch(options).always(resolve); }.bind(this)).then(function() { if (unreadCount > 0) { - if (unreadCount <= startingLoadedUnread) { + var loadedUnread = this.getLoadedUnreadCount(); + if (loadedUnread >= unreadCount) { return; } - var loadedUnread = this.getLoadedUnreadCount(); if (startingLoadedUnread === loadedUnread) { // that fetch didn't get us any more unread. stop fetching more. return;