From aa80cdd74da4ff98e8a85e393aab7c6818a1bbf1 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Wed, 12 Jul 2017 17:14:22 -0700 Subject: [PATCH] ConfirmationDialogView: Make showCancel an explicit option Also, don't call resolve/reject callbacks if they weren't provided. FREEBIE --- js/views/confirmation_dialog_view.js | 11 ++++++++--- js/views/message_detail_view.js | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/js/views/confirmation_dialog_view.js b/js/views/confirmation_dialog_view.js index 17d248f6a..f22ba48e0 100644 --- a/js/views/confirmation_dialog_view.js +++ b/js/views/confirmation_dialog_view.js @@ -10,6 +10,7 @@ templateName: 'confirmation-dialog', initialize: function(options) { this.message = options.message; + this.hideCancel = options.hideCancel; this.resolve = options.resolve; this.okText = options.okText || i18n('ok'); @@ -27,18 +28,22 @@ render_attributes: function() { return { message: this.message, - showCancel: Boolean(this.reject), + showCancel: !this.hideCancel, cancel: this.cancelText, ok: this.okText }; }, ok: function() { this.remove(); - this.resolve(); + if (this.resolve) { + this.resolve(); + } }, cancel: function() { this.remove(); - this.reject(); + if (this.reject) { + this.reject(); + } }, onKeyup: function(event) { if (event.key === 'Escape' || event.key === 'Esc') { diff --git a/js/views/message_detail_view.js b/js/views/message_detail_view.js index 46240e5f9..6dade8364 100644 --- a/js/views/message_detail_view.js +++ b/js/views/message_detail_view.js @@ -96,11 +96,11 @@ var dialog = new Whisper.ConfirmationDialogView({ message: i18n('deleteWarning'), okText: i18n('delete'), + hideCancel: true, resolve: function() { this.model.destroy(); this.resetPanel(); - }.bind(this), - reject: function() {} + }.bind(this) }); this.$el.prepend(dialog.el);