diff --git a/js/src/forum/components/IndexPage.js b/js/src/forum/components/IndexPage.js index a8cc4b6fb..03d5e64a2 100644 --- a/js/src/forum/components/IndexPage.js +++ b/js/src/forum/components/IndexPage.js @@ -164,7 +164,11 @@ export default class IndexPage extends Page { icon: 'fas fa-edit', className: 'Button Button--primary IndexPage-newDiscussion', itemClassName: 'App-primaryControl', - onclick: this.newDiscussionAction.bind(this), + onclick: () => { + // If the user is not logged in, the promise rejects, and a login modal shows up. + // Since that's already handled, we dont need to show an error message in the console. + return this.newDiscussionAction().catch(() => { }); + }, disabled: !canStartDiscussion, }, app.translator.trans(canStartDiscussion ? 'core.forum.index.start_discussion_button' : 'core.forum.index.cannot_start_discussion_button') diff --git a/js/src/forum/utils/DiscussionControls.js b/js/src/forum/utils/DiscussionControls.js index 283a8a2eb..4cdc8665b 100644 --- a/js/src/forum/utils/DiscussionControls.js +++ b/js/src/forum/utils/DiscussionControls.js @@ -56,22 +56,26 @@ export default { 'reply', !app.session.user || discussion.canReply() ? Button.component( - { - icon: 'fas fa-reply', - onclick: this.replyAction.bind(discussion, true, false), + { + icon: 'fas fa-reply', + onclick: () => { + // If the user is not logged in, the promise rejects, and a login modal shows up. + // Since that's already handled, we dont need to show an error message in the console. + return this.replyAction(discussion, true, false).catch(() => { }); }, - app.translator.trans( - app.session.user ? 'core.forum.discussion_controls.reply_button' : 'core.forum.discussion_controls.log_in_to_reply_button' - ) + }, + app.translator.trans( + app.session.user ? 'core.forum.discussion_controls.reply_button' : 'core.forum.discussion_controls.log_in_to_reply_button' ) + ) : 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') - ) + { + 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') + ) ); }