From a60ad77bdcde3fffbaf343b8c5d8bd35e9633dac Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Sat, 16 Oct 2021 20:44:39 +0200 Subject: [PATCH] fix: use async action to change current list --- src/components/home/navigation.vue | 2 +- src/views/list/ShowList.vue | 2 +- src/views/list/settings/background.vue | 6 +++--- src/views/list/settings/edit.vue | 2 +- src/views/list/settings/share.vue | 2 +- src/views/tasks/TaskDetailView.vue | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/home/navigation.vue b/src/components/home/navigation.vue index 1b3d54dc4..162589856 100644 --- a/src/components/home/navigation.vue +++ b/src/components/home/navigation.vue @@ -117,7 +117,7 @@ @click="navigate" :href="href" class="list-menu-link" - :class="{'router-link-exact-active': isActive || currentList.id === l.id}" + :class="{'router-link-exact-active': isActive || currentList?.id === l.id}" > diff --git a/src/views/list/ShowList.vue b/src/views/list/ShowList.vue index 0877e7001..68e417d9e 100644 --- a/src/views/list/ShowList.vue +++ b/src/views/list/ShowList.vue @@ -139,7 +139,7 @@ export default { const list = new ListModel(listData) try { const loadedList = await this.listService.get(list) - this.$store.commit(CURRENT_LIST, loadedList) + await this.$store.dispatch(CURRENT_LIST, loadedList) this.setTitle(this.getListTitle(loadedList)) } finally { this.listLoaded = this.$route.params.listId diff --git a/src/views/list/settings/background.vue b/src/views/list/settings/background.vue index a6b5e01bb..41e8b319a 100644 --- a/src/views/list/settings/background.vue +++ b/src/views/list/settings/background.vue @@ -137,7 +137,7 @@ export default { } const list = await this.backgroundService.update({id: backgroundId, listId: this.$route.params.listId}) - this.$store.commit(CURRENT_LIST, list) + await this.$store.dispatch(CURRENT_LIST, list) this.$store.commit('namespaces/setListInNamespaceById', list) this.$message.success({message: this.$t('list.background.success')}) }, @@ -148,14 +148,14 @@ export default { } const list = await this.backgroundUploadService.create(this.$route.params.listId, this.$refs.backgroundUploadInput.files[0]) - this.$store.commit(CURRENT_LIST, list) + await this.$store.dispatch(CURRENT_LIST, list) this.$store.commit('namespaces/setListInNamespaceById', list) this.$message.success({message: this.$t('list.background.success')}) }, async removeBackground() { const list = await this.listService.removeBackground(this.currentList) - this.$store.commit(CURRENT_LIST, list) + await this.$store.dispatch(CURRENT_LIST, list) this.$store.commit('namespaces/setListInNamespaceById', list) this.$message.success({message: this.$t('list.background.removeSuccess')}) this.$router.back() diff --git a/src/views/list/settings/edit.vue b/src/views/list/settings/edit.vue index 8838cd09e..558925190 100644 --- a/src/views/list/settings/edit.vue +++ b/src/views/list/settings/edit.vue @@ -103,7 +103,7 @@ export default { async save() { await this.$store.dispatch('lists/updateList', this.list) - this.$store.commit(CURRENT_LIST, this.list) + await this.$store.dispatch(CURRENT_LIST, this.list) this.setTitle(this.$t('list.edit.title', {list: this.list.title})) this.$message.success({message: this.$t('list.edit.success')}) this.$router.back() diff --git a/src/views/list/settings/share.vue b/src/views/list/settings/share.vue index 8820a2669..4a9967f86 100644 --- a/src/views/list/settings/share.vue +++ b/src/views/list/settings/share.vue @@ -60,7 +60,7 @@ export default { const list = new ListModel({id: this.$route.params.listId}) this.list = await this.listService.get(list) - this.$store.commit(CURRENT_LIST, this.list) + await this.$store.dispatch(CURRENT_LIST, this.list) // This will trigger the dynamic loading of components once we actually have all the data to pass to them this.manageTeamsComponent = 'userTeam' this.manageUsersComponent = 'userTeam' diff --git a/src/views/tasks/TaskDetailView.vue b/src/views/tasks/TaskDetailView.vue index b7485fbd2..4b88aae20 100644 --- a/src/views/tasks/TaskDetailView.vue +++ b/src/views/tasks/TaskDetailView.vue @@ -510,7 +510,7 @@ export default { }, parent: { handler(parent) { - this.$store.commit(CURRENT_LIST, parent !== null ? parent.list : this.currentList) + this.$store.dispatch(CURRENT_LIST, parent !== null ? parent.list : this.currentList) }, immediate: true, },