Keep last seen indicator around for five seconds
Helps calm the user experience a little more, makes it easier to understand what's happening when messages are coming in quickly. FREEBIE
This commit is contained in:
parent
4e9e811d12
commit
01918049b4
3 changed files with 34 additions and 3 deletions
|
@ -5,12 +5,27 @@
|
|||
'use strict';
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
var FIVE_SECONDS = 5 * 1000;
|
||||
|
||||
Whisper.LastSeenIndicatorView = Whisper.View.extend({
|
||||
className: 'last-seen-indicator-view',
|
||||
templateName: 'last-seen-indicator-view',
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
this.count = options.count || 0;
|
||||
this.start = Date.now();
|
||||
},
|
||||
|
||||
isOldEnough: function() {
|
||||
var now = Date.now();
|
||||
if (now - this.start > FIVE_SECONDS) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
increment: function(count) {
|
||||
this.count += count;
|
||||
this.render();
|
||||
},
|
||||
|
||||
render_attributes: function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue