From e0f84d9c8e659db080fd16b68bef3478f96e94d7 Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 27 Aug 2015 14:36:32 -0700 Subject: [PATCH] Clear unread on focus iff convo is open --- js/views/conversation_view.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index 415179ba7..6142c52b5 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -56,12 +56,16 @@ var onResize = this.forceUpdateMessageFieldSize.bind(this); this.appWindow.contentWindow.addEventListener('resize', onResize); - var onfocus = this.markRead.bind(this); - this.appWindow.contentWindow.addEventListener('focus', onfocus); + var onFocus = function() { + if (this.$el.css('display') !== 'none') { + this.markRead(); + } + }.bind(this); + this.appWindow.contentWindow.addEventListener('focus', onFocus); this.appWindow.onClosed.addListener(function () { this.appWindow.contentWindow.removeEventListener('resize', onResize); - this.appWindow.contentWindow.removeEventListener('focus', onfocus); + this.appWindow.contentWindow.removeEventListener('focus', onFocus); window.autosize.destroy(this.$messageField); this.remove(); }.bind(this));