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