Clean up redundant repetition

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

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

Loading…
Cancel
Save