Hide call buttons when on call

This commit is contained in:
Evan Hahn 2020-10-30 12:52:21 -05:00 committed by Evan Hahn
parent a7854c6083
commit decc93532b
18 changed files with 622 additions and 366 deletions

View file

@ -1,9 +1,6 @@
/* global
_,
Backbone,
i18n,
MessageController,
moment,
Whisper
*/
@ -98,59 +95,4 @@
},
update: debouncedCheckExpiringMessages,
};
const TimerOption = Backbone.Model.extend({
getName() {
return (
i18n(['timerOption', this.get('time'), this.get('unit')].join('_')) ||
moment.duration(this.get('time'), this.get('unit')).humanize()
);
},
getAbbreviated() {
return i18n(
['timerOption', this.get('time'), this.get('unit'), 'abbreviated'].join(
'_'
)
);
},
});
Whisper.ExpirationTimerOptions = new (Backbone.Collection.extend({
model: TimerOption,
getName(seconds = 0) {
const o = this.findWhere({ seconds });
if (o) {
return o.getName();
}
return [seconds, 'seconds'].join(' ');
},
getAbbreviated(seconds = 0) {
const o = this.findWhere({ seconds });
if (o) {
return o.getAbbreviated();
}
return [seconds, 's'].join('');
},
}))(
[
[0, 'seconds'],
[5, 'seconds'],
[10, 'seconds'],
[30, 'seconds'],
[1, 'minute'],
[5, 'minutes'],
[30, 'minutes'],
[1, 'hour'],
[6, 'hours'],
[12, 'hours'],
[1, 'day'],
[1, 'week'],
].map(o => {
const duration = moment.duration(o[0], o[1]); // 5, 'seconds'
return {
time: o[0],
unit: o[1],
seconds: duration.asSeconds(),
};
})
);
})();