Skip to content

Commit

Permalink
ConversationView.markRead: Mark all messages read when at bottom
Browse files Browse the repository at this point in the history
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
  • Loading branch information
scottnonnenberg committed Jun 7, 2017
1 parent 6bfeb7a commit da8d49b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions js/views/conversation_view.js
Expand Up @@ -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() {
Expand Down Expand Up @@ -418,7 +419,7 @@

onClick: function(e) {
this.closeMenu(e);
this.markRead(e);
this.markRead();
},

findNewestVisibleUnread: function() {
Expand Down Expand Up @@ -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'));
}
Expand Down

0 comments on commit da8d49b

Please sign in to comment.