Merge pull request #478 from BeaudanBrown/clean-branches

Clean up redundant repetition of successive code duplication one after the other
pull/480/head
Beaudan Campbell-Brown 6 years ago committed by GitHub
commit 4836b74f60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1292,38 +1292,27 @@
}, },
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 dialog = new Whisper.ConfirmationDialogView({
message: warningMessage,
okText: i18n('delete'),
resolve: async () => {
if (this.model.isPublic()) {
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?
return; return;
} }
await window.Signal.Data.removeMessage(message.id, { } else {
Message: Whisper.Message, this.model.messageCollection.remove(message.id);
}); }
message.trigger('unload'); await window.Signal.Data.removeMessage(message.id, {
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, Message: Whisper.Message,
}); });
message.trigger('unload'); message.trigger('unload');
this.model.messageCollection.remove(message.id);
this.resetPanel(); this.resetPanel();
this.updateHeader(); this.updateHeader();
}, },
@ -1511,37 +1500,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