Mute conversations
This commit is contained in:
parent
de7a69dee9
commit
84e52c948b
12 changed files with 185 additions and 3 deletions
|
@ -499,6 +499,7 @@
|
|||
? undefined
|
||||
: (this.get('members') || []).length,
|
||||
messageRequestsEnabled,
|
||||
muteExpiresAt: this.get('muteExpiresAt'),
|
||||
name: this.get('name'),
|
||||
phoneNumber: this.getNumber(),
|
||||
profileName: this.getProfileName(),
|
||||
|
@ -2844,6 +2845,10 @@
|
|||
},
|
||||
|
||||
async notify(message, reaction) {
|
||||
if (this.get('muteExpiresAt') && Date.now() < this.get('muteExpiresAt')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!message.isIncoming() && !reaction) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -357,6 +357,24 @@
|
|||
paste: 'onPaste',
|
||||
},
|
||||
|
||||
getMuteExpirationLabel() {
|
||||
const muteExpiresAt = this.model.get('muteExpiresAt');
|
||||
if (!muteExpiresAt) {
|
||||
return;
|
||||
}
|
||||
|
||||
const today = window.moment(Date.now());
|
||||
const expires = window.moment(muteExpiresAt);
|
||||
|
||||
if (today.isSame(expires, 'day')) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return expires.format('hh:mm A');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
return expires.format('M/D/YY, hh:mm A');
|
||||
},
|
||||
|
||||
setupHeader() {
|
||||
const getHeaderProps = () => {
|
||||
const expireTimer = this.model.get('expireTimer');
|
||||
|
@ -376,6 +394,8 @@
|
|||
value: item.get('seconds'),
|
||||
})),
|
||||
|
||||
muteExpirationLabel: this.getMuteExpirationLabel(),
|
||||
|
||||
onSetDisappearingMessages: seconds =>
|
||||
this.setDisappearingMessages(seconds),
|
||||
onDeleteMessages: () => this.destroyMessages(),
|
||||
|
@ -387,6 +407,7 @@
|
|||
: this.model.getTitle();
|
||||
searchInConversation(this.model.id, name);
|
||||
},
|
||||
onSetMuteNotifications: ms => this.setMuteNotifications(ms),
|
||||
|
||||
// These are view only and don't update the Conversation model, so they
|
||||
// need a manual update call.
|
||||
|
@ -2485,6 +2506,12 @@
|
|||
}
|
||||
},
|
||||
|
||||
setMuteNotifications(ms) {
|
||||
this.model.set({
|
||||
muteExpiresAt: ms > 0 ? Date.now() + ms : undefined,
|
||||
});
|
||||
},
|
||||
|
||||
async destroyMessages() {
|
||||
try {
|
||||
await this.confirm(i18n('deleteConversationConfirmation'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue