From feff1a1e7ab65c1a0c0e3d9e3bf3e3a378ded1a9 Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Sat, 19 Oct 2024 11:55:05 +0100 Subject: [PATCH] fix: post reply error --- .../js/src/forum/states/ComposerState.tsx | 3 ++ .../js/src/forum/utils/DiscussionControls.js | 48 +++++++++---------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/framework/core/js/src/forum/states/ComposerState.tsx b/framework/core/js/src/forum/states/ComposerState.tsx index ace876cbb..a9e523348 100644 --- a/framework/core/js/src/forum/states/ComposerState.tsx +++ b/framework/core/js/src/forum/states/ComposerState.tsx @@ -111,6 +111,9 @@ class ComposerState { this.position = ComposerState.Position.NORMAL; m.redraw.sync(); + + // Sleep for a short time to allow the composer to render before subsequent actions. + await new Promise((resolve) => setTimeout(resolve, 80)); } /** diff --git a/framework/core/js/src/forum/utils/DiscussionControls.js b/framework/core/js/src/forum/utils/DiscussionControls.js index 2ba15c781..6e12671ce 100644 --- a/framework/core/js/src/forum/utils/DiscussionControls.js +++ b/framework/core/js/src/forum/utils/DiscussionControls.js @@ -159,37 +159,33 @@ const DiscussionControls = { * @param {boolean} goToLast Whether or not to scroll down to the last post if the discussion is being viewed. * @param {boolean} forceRefresh Whether or not to force a reload of the composer component, even if it is already open for this discussion. * - * @return {Promise} + * @return {Promise} */ - replyAction(goToLast, forceRefresh) { - return new Promise((resolve, reject) => { - if (app.session.user) { - if (this.canReply()) { - if (!app.composer.composingReplyTo(this) || forceRefresh) { - app.composer - .load(() => import('../components/ReplyComposer'), { - user: app.session.user, - discussion: this, - }) - .then(() => app.composer.show()); - } else { - app.composer.show(); - } - - if (goToLast && app.viewingDiscussion(this) && !app.composer.isFullScreen()) { - app.current.get('stream').goToNumber('reply'); - } - - return resolve(app.composer); - } else { - return reject(); + async replyAction(goToLast, forceRefresh) { + if (app.session.user) { + if (this.canReply()) { + if (!app.composer.composingReplyTo(this) || forceRefresh) { + await app.composer.load(() => import('../components/ReplyComposer'), { + user: app.session.user, + discussion: this, + }); } + + await app.composer.show(); + + if (goToLast && app.viewingDiscussion(this) && !app.composer.isFullScreen()) { + await app.current.get('stream').goToNumber('reply'); + } + + return Promise.resolve(app.composer); + } else { + return Promise.reject(); } + } - app.modal.show(() => import('../components/LogInModal')); + await app.modal.show(() => import('../components/LogInModal')); - return reject(); - }); + return Promise.reject(); }, /**