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,25 +1309,21 @@
message.trigger('unload'); message.trigger('unload');
this.resetPanel(); this.resetPanel();
this.updateHeader(); this.updateHeader();
}, }
}); : () => {
window.Signal.Data.removeMessage(message.id, {
Message: Whisper.Message,
});
message.trigger('unload');
this.model.messageCollection.remove(message.id);
this.resetPanel();
this.updateHeader();
};
this.$el.prepend(dialog.el);
dialog.focusCancel();
return;
}
const dialog = new Whisper.ConfirmationDialogView({ const dialog = new Whisper.ConfirmationDialogView({
message: i18n('deleteWarning'), message: warningMessage,
okText: i18n('delete'), okText: i18n('delete'),
resolve: () => { resolve,
window.Signal.Data.removeMessage(message.id, {
Message: Whisper.Message,
});
message.trigger('unload');
this.model.messageCollection.remove(message.id);
this.resetPanel();
this.updateHeader();
},
}); });
this.$el.prepend(dialog.el); this.$el.prepend(dialog.el);
@ -1511,37 +1508,24 @@
}, },
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 { Whisper.events.trigger('showConfirmationDialog', {
await this.model.destroyMessages(); message,
this.unload('delete messages'); onOk: async () => {
} catch (error) { try {
window.log.error( await this.model.destroyMessages();
'destroyMessages: Failed to successfully delete conversation', this.unload('delete messages');
error && error.stack ? error.stack : error } catch (error) {
); window.log.error(
} 'destroyMessages: Failed to successfully delete conversation',
}, error && error.stack ? error.stack : error
}); );
} else { }
Whisper.events.trigger('showConfirmationDialog', { },
message: 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
);
}
},
});
}
}, },
showSendConfirmationDialog(e, contacts) { showSendConfirmationDialog(e, contacts) {

Loading…
Cancel
Save