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
This commit is contained in:
parent
bb468e7b01
commit
017bb56cca
3 changed files with 2 additions and 16 deletions
|
@ -116,7 +116,7 @@
|
||||||
|
|
||||||
var onFocus = function() {
|
var onFocus = function() {
|
||||||
if (this.$el.css('display') !== 'none') {
|
if (this.$el.css('display') !== 'none') {
|
||||||
this.markRead();
|
this.updateUnread();
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
this.window.addEventListener('focus', onFocus);
|
this.window.addEventListener('focus', onFocus);
|
||||||
|
@ -324,11 +324,8 @@
|
||||||
this.model.messageCollection.add(message, {merge: true});
|
this.model.messageCollection.add(message, {merge: true});
|
||||||
message.setToExpire();
|
message.setToExpire();
|
||||||
|
|
||||||
if (this.lastSeenIndicator) {
|
|
||||||
this.lastSeenIndicator.increment(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.isHidden() && window.isFocused()) {
|
if (!this.isHidden() && window.isFocused()) {
|
||||||
|
this.removeLastSeenIndicator();
|
||||||
this.markRead();
|
this.markRead();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,11 +13,6 @@
|
||||||
this.count = options.count || 0;
|
this.count = options.count || 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
increment: function(count) {
|
|
||||||
this.count += count;
|
|
||||||
this.render();
|
|
||||||
},
|
|
||||||
|
|
||||||
render_attributes: function() {
|
render_attributes: function() {
|
||||||
var unreadMessages = this.count === 1 ? i18n('unreadMessage')
|
var unreadMessages = this.count === 1 ? i18n('unreadMessage')
|
||||||
: i18n('unreadMessages', [this.count]);
|
: i18n('unreadMessages', [this.count]);
|
||||||
|
|
|
@ -9,10 +9,4 @@ describe('LastSeenIndicatorView', function() {
|
||||||
assert.equal(view.count, 10);
|
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);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue