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
This commit is contained in:
Scott Nonnenberg 2017-06-07 09:51:59 -07:00
parent 6bfeb7ab14
commit da8d49b5ed

View file

@ -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'));
}