2018-07-07 00:48:14 +00:00
|
|
|
/* global Whisper, i18n */
|
|
|
|
|
|
|
|
// eslint-disable-next-line func-names
|
2018-04-27 21:25:04 +00:00
|
|
|
(function() {
|
|
|
|
'use strict';
|
2017-05-17 21:32:03 +00:00
|
|
|
|
2018-07-07 00:48:14 +00:00
|
|
|
window.Whisper = window.Whisper || {};
|
2017-05-25 18:28:31 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
Whisper.LastSeenIndicatorView = Whisper.View.extend({
|
2018-07-09 21:29:13 +00:00
|
|
|
className: 'module-last-seen-indicator',
|
2018-04-27 21:25:04 +00:00
|
|
|
templateName: 'last-seen-indicator-view',
|
2018-07-07 00:48:14 +00:00
|
|
|
initialize(options = {}) {
|
2018-04-27 21:25:04 +00:00
|
|
|
this.count = options.count || 0;
|
|
|
|
},
|
2017-05-25 18:28:31 +00:00
|
|
|
|
2018-07-07 00:48:14 +00:00
|
|
|
increment(count) {
|
2018-04-27 21:25:04 +00:00
|
|
|
this.count += count;
|
|
|
|
this.render();
|
|
|
|
},
|
2017-05-17 21:32:03 +00:00
|
|
|
|
2018-07-07 00:48:14 +00:00
|
|
|
getCount() {
|
2018-04-27 21:25:04 +00:00
|
|
|
return this.count;
|
|
|
|
},
|
2017-06-01 18:54:57 +00:00
|
|
|
|
2018-07-07 00:48:14 +00:00
|
|
|
render_attributes() {
|
|
|
|
const unreadMessages =
|
2018-04-27 21:25:04 +00:00
|
|
|
this.count === 1
|
|
|
|
? i18n('unreadMessage')
|
|
|
|
: i18n('unreadMessages', [this.count]);
|
2017-05-17 21:32:03 +00:00
|
|
|
|
2018-04-27 21:25:04 +00:00
|
|
|
return {
|
2018-07-07 00:48:14 +00:00
|
|
|
unreadMessages,
|
2018-04-27 21:25:04 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2017-05-17 21:32:03 +00:00
|
|
|
})();
|