From d5fb6c568c87162a068738096c23987c61ec5e3e Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sun, 15 Sep 2019 10:45:52 -0700 Subject: [PATCH] fix: ignore rapid Ctrl-Enter inputs when composing (#1488) fixes #421 --- .../_components/compose/ComposeBox.html | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/routes/_components/compose/ComposeBox.html b/src/routes/_components/compose/ComposeBox.html index a8197166..7517b932 100644 --- a/src/routes/_components/compose/ComposeBox.html +++ b/src/routes/_components/compose/ComposeBox.html @@ -145,7 +145,8 @@ autoFocus: false, hideBottomBorder: false, hidden: false, - dialogId: undefined + dialogId: undefined, + aboutToPostStatus: false }), store: () => store, computed: { @@ -184,12 +185,22 @@ slide }, methods: { - doPostStatus () { + async doPostStatus () { + const { aboutToPostStatus } = this.get() + const { postingStatus } = this.store.get() + if (aboutToPostStatus || postingStatus) { // do nothing if the user rapidly taps the Ctrl-Enter key + console.log('ignored post command', { aboutToPostStatus, postingStatus }) + return + } // The reason we add a scheduleIdleTask delay here is because we also use scheduleIdleTask // in ComposeInput.html to debounce the input events. If the user is very fast at typing // at their keyboard and quickly presses Ctrl+Enter or the "Toot" button then there could // be a race condition where not all of their status is posted. - scheduleIdleTask(() => this.doPostStatusAfterDelay()) + this.set({ aboutToPostStatus: true }) + scheduleIdleTask(() => { + this.set({ aboutToPostStatus: false }) + this.doPostStatusAfterDelay() + }) }, doPostStatusAfterDelay () { const { @@ -228,8 +239,7 @@ options: poll.options } - /* no await */ - postStatus(realm, text, inReplyTo, mediaIds, + /* no await */ postStatus(realm, text, inReplyTo, mediaIds, sensitive, contentWarning, postPrivacyKey, mediaDescriptions, inReplyToUuid, pollToPost, mediaFocalPoints)