signal-desktop/js/views/last_seen_indicator_view.js

37 lines
726 B
JavaScript
Raw Normal View History

/* global Whisper, i18n */
// eslint-disable-next-line func-names
2018-04-27 21:25:04 +00:00
(function() {
'use strict';
window.Whisper = window.Whisper || {};
2018-04-27 21:25:04 +00:00
Whisper.LastSeenIndicatorView = Whisper.View.extend({
className: 'module-last-seen-indicator',
2018-04-27 21:25:04 +00:00
templateName: 'last-seen-indicator-view',
initialize(options = {}) {
2018-04-27 21:25:04 +00:00
this.count = options.count || 0;
},
increment(count) {
2018-04-27 21:25:04 +00:00
this.count += count;
this.render();
},
getCount() {
2018-04-27 21:25:04 +00:00
return this.count;
},
render_attributes() {
const unreadMessages =
2018-04-27 21:25:04 +00:00
this.count === 1
? i18n('unreadMessage')
: i18n('unreadMessages', [this.count]);
2018-04-27 21:25:04 +00:00
return {
unreadMessages,
2018-04-27 21:25:04 +00:00
};
},
});
})();