Prevent multiple toot submissions

This commit is contained in:
L. E. Segovia 2018-12-12 00:50:57 +00:00
parent 97050fdbe1
commit 66c5c3df35
No known key found for this signature in database
GPG Key ID: D5D1DC48B52B7AD5
1 changed files with 9 additions and 0 deletions

View File

@ -95,6 +95,10 @@ const NewToot = {
if (rootState.TimelineSpace.account.accessToken === undefined || rootState.TimelineSpace.account.accessToken === null) { if (rootState.TimelineSpace.account.accessToken === undefined || rootState.TimelineSpace.account.accessToken === null) {
throw new AuthenticationError() throw new AuthenticationError()
} }
if (state.blockSubmit) {
return
}
commit('changeBlockSubmit', true)
const client = new Mastodon( const client = new Mastodon(
rootState.TimelineSpace.account.accessToken, rootState.TimelineSpace.account.accessToken,
rootState.TimelineSpace.account.baseURL + '/api/v1' rootState.TimelineSpace.account.baseURL + '/api/v1'
@ -102,8 +106,13 @@ const NewToot = {
return client.post('/statuses', form) return client.post('/statuses', form)
.then(res => { .then(res => {
ipcRenderer.send('toot-action-sound') ipcRenderer.send('toot-action-sound')
commit('changeBlockSubmit', false)
return res.data return res.data
}) })
.catch(e => {
commit('changeBlockSubmit', false)
throw e
})
}, },
openReply ({ dispatch, commit, rootState }, message) { openReply ({ dispatch, commit, rootState }, message) {
commit('setReplyTo', message) commit('setReplyTo', message)