From 1c8e26bdc615a3477c139f3d8128d71c71027c43 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sun, 17 Oct 2021 15:16:26 +0200 Subject: [PATCH] fix: set the current list when opening a task --- src/store/index.js | 12 ++++++------ src/views/tasks/TaskDetailView.vue | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 9d44d2da..dec5ece0 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -63,6 +63,12 @@ export const store = createStore({ state.online = !!import.meta.env.VITE_IS_ONLINE || online }, [CURRENT_LIST](state, currentList) { + // Server updates don't return the right. Therefore the right is reset after updating the list which is + // confusing because all the buttons will disappear in that case. To prevent this, we're keeping the right + // when updating the list in global state. + if (typeof state.currentList.maxRight !== 'undefined' && (typeof currentList.maxRight === 'undefined' || currentList.maxRight === null)) { + currentList.maxRight = state.currentList.maxRight + } state.currentList = currentList }, [HAS_TASKS](state, hasTasks) { @@ -135,12 +141,6 @@ export const store = createStore({ commit(BACKGROUND, null) } - // Server updates don't return the right. Therefore the right is reset after updating the list which is - // confusing because all the buttons will disappear in that case. To prevent this, we're keeping the right - // when updating the list in global state. - if (typeof state.currentList.maxRight !== 'undefined' && (typeof currentList.maxRight === 'undefined' || currentList.maxRight === null)) { - currentList.maxRight = state.currentList.maxRight - } commit(CURRENT_LIST, currentList) }, }, diff --git a/src/views/tasks/TaskDetailView.vue b/src/views/tasks/TaskDetailView.vue index 4ada14bf..20c9d145 100644 --- a/src/views/tasks/TaskDetailView.vue +++ b/src/views/tasks/TaskDetailView.vue @@ -510,7 +510,10 @@ export default { }, parent: { handler(parent) { - this.$store.commit(CURRENT_LIST, parent !== null ? parent.list : this.currentList) + const parentList = parent !== null ? parent.list : null + if (parentList !== null) { + this.$store.commit(CURRENT_LIST, parentList) + } }, immediate: true, },