diff options
author | dartcafe <github@dartcafe.de> | 2021-02-27 13:10:48 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2021-02-27 13:10:48 +0300 |
commit | 985fa6e5ebc878b00c64cd371079e45a491d2b58 (patch) | |
tree | a9a56b8afb4c56e316fddea30073f7e0ed280c7a /src/js/components/SideBar/SideBarTabConfiguration.vue | |
parent | 7a05a361da2b5e0879e9e83dcb2f6d9fa3009671 (diff) |
use async/await
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'src/js/components/SideBar/SideBarTabConfiguration.vue')
-rw-r--r-- | src/js/components/SideBar/SideBarTabConfiguration.vue | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/src/js/components/SideBar/SideBarTabConfiguration.vue b/src/js/components/SideBar/SideBarTabConfiguration.vue index 2b9cba27..d7041b26 100644 --- a/src/js/components/SideBar/SideBarTabConfiguration.vue +++ b/src/js/components/SideBar/SideBarTabConfiguration.vue @@ -114,10 +114,7 @@ export default { data() { return { - writingPoll: false, - sidebar: false, titleEmpty: false, - setExpiration: false, accessOptions: [ { value: 'hidden', label: t('polls', 'Only invited users') }, { value: 'public', label: t('polls', 'All users') }, @@ -337,7 +334,6 @@ export default { writeValue(e) { this.$store.commit('poll/setProperty', e) - this.writingPoll = true this.updatePoll() }, @@ -359,32 +355,27 @@ export default { }, - deletePermanently() { + async deletePermanently() { if (!this.poll.deleted) return - - this.$store - .dispatch('poll/delete', { pollId: this.poll.id }) - .then(() => { - emit('update-polls') - this.$router.push({ name: 'list', params: { type: 'relevant' } }) - }) - .catch(() => { - showError(t('polls', 'Error deleting poll.')) - }) + try { + await this.$store.dispatch('poll/delete', { pollId: this.poll.id }) + emit('update-polls') + this.$router.push({ name: 'list', params: { type: 'relevant' } }) + } catch (e) { + showError(t('polls', 'Error deleting poll.')) + } }, - updatePoll() { + async updatePoll() { if (this.titleEmpty) { showError(t('polls', 'Title must not be empty!')) } else { - this.$store.dispatch('poll/update') - .then((response) => { - this.successDebounced(response) - }) - .catch(() => { - showError(t('polls', 'Error writing poll')) - }) - this.writingPoll = false + try { + const response = await this.$store.dispatch('poll/update') + this.successDebounced(response) + } catch (e) { + showError(t('polls', 'Error writing poll')) + } } }, |