Automatically mark the open conversation read

If a conversation view is visible, it will automatically mark the
conversation read.

// FREEBIE
This commit is contained in:
lilia 2015-09-15 20:50:00 -07:00
parent 15a366dbf0
commit 9809894fd2

View file

@ -24,6 +24,7 @@
this.listenTo(this.model, 'destroy', this.stopListening); this.listenTo(this.model, 'destroy', this.stopListening);
this.listenTo(this.model, 'change:name', this.updateTitle); this.listenTo(this.model, 'change:name', this.updateTitle);
this.listenTo(this.model, 'newmessages', this.fetchMessages); this.listenTo(this.model, 'newmessages', this.fetchMessages);
this.listenTo(this.model, 'change:unreadCount', this.onUnread);
this.render(); this.render();
@ -104,6 +105,12 @@
this.model.markRead(); this.model.markRead();
}, },
onUnread: function(model, previous) {
if (!this.isHidden()) {
this.markRead();
}
},
verifyIdentity: function() { verifyIdentity: function() {
if (this.model.isPrivate()) { if (this.model.isPrivate()) {
var their_number = this.model.id; var their_number = this.model.id;
@ -233,12 +240,16 @@
}, },
forceUpdateMessageFieldSize: function (event) { forceUpdateMessageFieldSize: function (event) {
if (this.$el.css('display') === 'none') { if (this.isHidden()) {
return; return;
} }
this.view.scrollToBottomIfNeeded(); this.view.scrollToBottomIfNeeded();
window.autosize.update(this.$messageField); window.autosize.update(this.$messageField);
this.updateMessageFieldSize(event); this.updateMessageFieldSize(event);
},
isHidden: function() {
return (this.$el.css('display') === 'none');
} }
}); });
})(); })();