diff --git a/js/src/forum/utils/DiscussionControls.js b/js/src/forum/utils/DiscussionControls.js index 7a49dcab8..283a8a2eb 100644 --- a/js/src/forum/utils/DiscussionControls.js +++ b/js/src/forum/utils/DiscussionControls.js @@ -55,19 +55,23 @@ export default { items.add( 'reply', !app.session.user || discussion.canReply() - ? Button.component({ - icon: 'fas fa-reply', - children: app.translator.trans( + ? Button.component( + { + icon: 'fas fa-reply', + onclick: this.replyAction.bind(discussion, true, false), + }, + app.translator.trans( app.session.user ? 'core.forum.discussion_controls.reply_button' : 'core.forum.discussion_controls.log_in_to_reply_button' - ), - onclick: this.replyAction.bind(discussion, true, false), - }) - : Button.component({ - icon: 'fas fa-reply', - children: app.translator.trans('core.forum.discussion_controls.cannot_reply_button'), - className: 'disabled', - title: app.translator.trans('core.forum.discussion_controls.cannot_reply_text'), - }) + ) + ) + : Button.component( + { + icon: 'fas fa-reply', + className: 'disabled', + title: app.translator.trans('core.forum.discussion_controls.cannot_reply_text'), + }, + app.translator.trans('core.forum.discussion_controls.cannot_reply_button') + ) ); } @@ -89,11 +93,13 @@ export default { if (discussion.canRename()) { items.add( 'rename', - Button.component({ - icon: 'fas fa-pencil-alt', - children: app.translator.trans('core.forum.discussion_controls.rename_button'), - onclick: this.renameAction.bind(discussion), - }) + Button.component( + { + icon: 'fas fa-pencil-alt', + onclick: this.renameAction.bind(discussion), + }, + app.translator.trans('core.forum.discussion_controls.rename_button') + ) ); } @@ -116,33 +122,39 @@ export default { if (discussion.canHide()) { items.add( 'hide', - Button.component({ - icon: 'far fa-trash-alt', - children: app.translator.trans('core.forum.discussion_controls.delete_button'), - onclick: this.hideAction.bind(discussion), - }) + Button.component( + { + icon: 'far fa-trash-alt', + onclick: this.hideAction.bind(discussion), + }, + app.translator.trans('core.forum.discussion_controls.delete_button') + ) ); } } else { if (discussion.canHide()) { items.add( 'restore', - Button.component({ - icon: 'fas fa-reply', - children: app.translator.trans('core.forum.discussion_controls.restore_button'), - onclick: this.restoreAction.bind(discussion), - }) + Button.component( + { + icon: 'fas fa-reply', + onclick: this.restoreAction.bind(discussion), + }, + app.translator.trans('core.forum.discussion_controls.restore_button') + ) ); } if (discussion.canDelete()) { items.add( 'delete', - Button.component({ - icon: 'fas fa-times', - children: app.translator.trans('core.forum.discussion_controls.delete_forever_button'), - onclick: this.deleteAction.bind(discussion), - }) + Button.component( + { + icon: 'fas fa-times', + onclick: this.deleteAction.bind(discussion), + }, + app.translator.trans('core.forum.discussion_controls.delete_forever_button') + ) ); } } @@ -163,33 +175,31 @@ export default { * @return {Promise} */ replyAction(goToLast, forceRefresh) { - const deferred = m.deferred(); + return new Promise((resolve, reject) => { + if (app.session.user) { + if (this.canReply()) { + if (!app.composer.composingReplyTo(this) || forceRefresh) { + app.composer.load(ReplyComposer, { + user: app.session.user, + discussion: this, + }); + } + app.composer.show(); - if (app.session.user) { - if (this.canReply()) { - if (!app.composer.composingReplyTo(this) || forceRefresh) { - app.composer.load(ReplyComposer, { - user: app.session.user, - discussion: this, - }); + if (goToLast && app.viewingDiscussion(this) && !app.composer.isFullScreen()) { + app.current.get('stream').goToNumber('reply'); + } + + return resolve(app.composer); + } else { + return reject(); } - app.composer.show(); - - if (goToLast && app.viewingDiscussion(this) && !app.composer.isFullScreen()) { - app.current.get('stream').goToNumber('reply'); - } - - deferred.resolve(app.composer); - } else { - deferred.reject(); } - } else { - deferred.reject(); app.modal.show(LogInModal); - } - return deferred.promise; + return reject(); + }); }, /**