From 017bb56cca78da1c8f179e6f47f4b3912fc2a10d Mon Sep 17 00:00:00 2001 From: lilia Date: Mon, 22 May 2017 14:13:37 -0700 Subject: [PATCH] Fix some corner casese with last seen indicator * Remove increment behavior * Dismiss when new messages arrive but the window is focused * Update the indicator when window becomes focused. // FREEBIE --- js/views/conversation_view.js | 7 ++----- js/views/last_seen_indicator_view.js | 5 ----- test/views/last_seen_indicator_view_test.js | 6 ------ 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index e802ac418..2647e16c7 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -116,7 +116,7 @@ var onFocus = function() { if (this.$el.css('display') !== 'none') { - this.markRead(); + this.updateUnread(); } }.bind(this); this.window.addEventListener('focus', onFocus); @@ -324,11 +324,8 @@ this.model.messageCollection.add(message, {merge: true}); message.setToExpire(); - if (this.lastSeenIndicator) { - this.lastSeenIndicator.increment(1); - } - if (!this.isHidden() && window.isFocused()) { + this.removeLastSeenIndicator(); this.markRead(); } }, diff --git a/js/views/last_seen_indicator_view.js b/js/views/last_seen_indicator_view.js index 0ce6a945a..08ed82945 100644 --- a/js/views/last_seen_indicator_view.js +++ b/js/views/last_seen_indicator_view.js @@ -13,11 +13,6 @@ this.count = options.count || 0; }, - increment: function(count) { - this.count += count; - this.render(); - }, - render_attributes: function() { var unreadMessages = this.count === 1 ? i18n('unreadMessage') : i18n('unreadMessages', [this.count]); diff --git a/test/views/last_seen_indicator_view_test.js b/test/views/last_seen_indicator_view_test.js index d293c6dde..8ae5d9f3c 100644 --- a/test/views/last_seen_indicator_view_test.js +++ b/test/views/last_seen_indicator_view_test.js @@ -9,10 +9,4 @@ describe('LastSeenIndicatorView', function() { assert.equal(view.count, 10); }); - it('increments count', function() { - var view = new Whisper.LastSeenIndicatorView({count: 4}); - assert.equal(view.count, 4); - view.increment(3); - assert.equal(view.count, 7); - }); });