Clean up redundant repetition

pull/478/head
Beaudan Brown 6 years ago
parent e70b875226
commit 3894f2784e

@ -1292,11 +1292,12 @@
}, },
deleteMessage(message) { deleteMessage(message) {
if (this.model.isPublic()) { const warningMessage = this.model.isPublic()
const dialog = new Whisper.ConfirmationDialogView({ ? i18n('deletePublicWarning')
message: i18n('deletePublicWarning'), : i18n('deleteWarning');
okText: i18n('delete'),
resolve: async () => { const resolve = this.model.isPublic()
? async () => {
const success = await this.model.deletePublicMessage(message); const success = await this.model.deletePublicMessage(message);
if (!success) { if (!success) {
// Message failed to delete from server, show error? // Message failed to delete from server, show error?
@ -1308,17 +1309,8 @@
message.trigger('unload'); message.trigger('unload');
this.resetPanel(); this.resetPanel();
this.updateHeader(); this.updateHeader();
},
});
this.$el.prepend(dialog.el);
dialog.focusCancel();
return;
} }
const dialog = new Whisper.ConfirmationDialogView({ : () => {
message: i18n('deleteWarning'),
okText: i18n('delete'),
resolve: () => {
window.Signal.Data.removeMessage(message.id, { window.Signal.Data.removeMessage(message.id, {
Message: Whisper.Message, Message: Whisper.Message,
}); });
@ -1326,7 +1318,12 @@
this.model.messageCollection.remove(message.id); this.model.messageCollection.remove(message.id);
this.resetPanel(); this.resetPanel();
this.updateHeader(); this.updateHeader();
}, };
const dialog = new Whisper.ConfirmationDialogView({
message: warningMessage,
okText: i18n('delete'),
resolve,
}); });
this.$el.prepend(dialog.el); this.$el.prepend(dialog.el);
@ -1511,24 +1508,12 @@
}, },
destroyMessages() { destroyMessages() {
if (this.model.isPublic()) { const message = this.model.isPublic()
Whisper.events.trigger('showConfirmationDialog', { ? i18n('deletePublicConversationConfirmation')
message: i18n('deletePublicConversationConfirmation'), : i18n('deleteConversationConfirmation');
onOk: async () => {
try {
await this.model.destroyMessages();
this.unload('delete messages');
} catch (error) {
window.log.error(
'destroyMessages: Failed to successfully delete conversation',
error && error.stack ? error.stack : error
);
}
},
});
} else {
Whisper.events.trigger('showConfirmationDialog', { Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deleteConversationConfirmation'), message,
onOk: async () => { onOk: async () => {
try { try {
await this.model.destroyMessages(); await this.model.destroyMessages();
@ -1541,7 +1526,6 @@
} }
}, },
}); });
}
}, },
showSendConfirmationDialog(e, contacts) { showSendConfirmationDialog(e, contacts) {

Loading…
Cancel
Save