From 66c5c3df35748d3686bcc629b3c9799487cf0fbd Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" <13498015+amyspark@users.noreply.github.com> Date: Wed, 12 Dec 2018 00:50:57 +0000 Subject: [PATCH] Prevent multiple toot submissions --- src/renderer/store/TimelineSpace/Modals/NewToot.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/renderer/store/TimelineSpace/Modals/NewToot.js b/src/renderer/store/TimelineSpace/Modals/NewToot.js index 7399cfa6..444a2ffe 100644 --- a/src/renderer/store/TimelineSpace/Modals/NewToot.js +++ b/src/renderer/store/TimelineSpace/Modals/NewToot.js @@ -95,6 +95,10 @@ const NewToot = { if (rootState.TimelineSpace.account.accessToken === undefined || rootState.TimelineSpace.account.accessToken === null) { throw new AuthenticationError() } + if (state.blockSubmit) { + return + } + commit('changeBlockSubmit', true) const client = new Mastodon( rootState.TimelineSpace.account.accessToken, rootState.TimelineSpace.account.baseURL + '/api/v1' @@ -102,8 +106,13 @@ const NewToot = { return client.post('/statuses', form) .then(res => { ipcRenderer.send('toot-action-sound') + commit('changeBlockSubmit', false) return res.data }) + .catch(e => { + commit('changeBlockSubmit', false) + throw e + }) }, openReply ({ dispatch, commit, rootState }, message) { commit('setReplyTo', message)