fix: ignore rapid Ctrl-Enter inputs when composing (#1488)

fixes #421
This commit is contained in:
Nolan Lawson 2019-09-15 10:45:52 -07:00 committed by GitHub
parent 35058ed965
commit d5fb6c568c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)