From 9809894fd2cf35b25b2cdd2d5dd7d5d7475532d9 Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 15 Sep 2015 20:50:00 -0700 Subject: [PATCH] Automatically mark the open conversation read If a conversation view is visible, it will automatically mark the conversation read. // FREEBIE --- js/views/conversation_view.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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'); } }); })();