From da8d49b5ed2dc6b7716be0744c725bd6f13152bc Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 7 Jun 2017 09:51:59 -0700 Subject: [PATCH] ConversationView.markRead: Mark all messages read when at bottom To handle the same 'not quite at the bottom' case that our 30px buffer gives us for marking messages read, we use the same atBottom() method to determine whether we should mark everything unread. Saves the effort and potential missed messages (due to partial pixels, etc.). FREEBIE --- js/views/conversation_view.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 72eb50114c..7b65ccec6d 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -217,7 +217,8 @@ }, updateUnread: function() { this.resetLastSeenIndicator(); - this.markRead(); + // Waiting for scrolling caused by resetLastSeenIndicator to settle down + setTimeout(this.markRead.bind(this), 1); }, onOpened: function() { @@ -418,7 +419,7 @@ onClick: function(e) { this.closeMenu(e); - this.markRead(e); + this.markRead(); }, findNewestVisibleUnread: function() { @@ -468,8 +469,15 @@ } }, - markRead: function(e) { - var unread = this.findNewestVisibleUnread(); + markRead: function() { + var unread; + + if (this.view.atBottom()) { + unread = this.model.messageCollection.last(); + } else { + unread = this.findNewestVisibleUnread(); + } + if (unread) { this.model.markRead(unread.get('received_at')); }