From 83c0ef4e8b34c78b4d77f11af8ea00797af84b44 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 21 Jun 2023 15:09:31 +0200 Subject: [PATCH] fix(project): set maxRight on projects after opening a task --- src/stores/base.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/stores/base.ts b/src/stores/base.ts index 9cd7491d5..f861376cc 100644 --- a/src/stores/base.ts +++ b/src/stores/base.ts @@ -11,6 +11,7 @@ import {useMenuActive} from '@/composables/useMenuActive' import {useAuthStore} from '@/stores/auth' import type {IProject} from '@/modelTypes/IProject' +import type {Right} from '@/constants/rights' export const useBaseStore = defineStore('base', () => { const loading = ref(false) @@ -38,6 +39,7 @@ export const useBaseStore = defineStore('base', () => { // Server updates don't return the right. Therefore, the right is reset after updating the project which is // confusing because all the buttons will disappear in that case. To prevent this, we're keeping the right // when updating the project in global state. + let maxRight: Right | null = newCurrentProject?.maxRight || null if ( typeof currentProject.value?.maxRight !== 'undefined' && newCurrentProject !== null && @@ -46,9 +48,16 @@ export const useBaseStore = defineStore('base', () => { newCurrentProject.maxRight === null ) ) { - newCurrentProject.maxRight = currentProject.value.maxRight + maxRight = currentProject.value.maxRight + } + if (newCurrentProject === null) { + currentProject.value = null + return + } + currentProject.value = { + ...newCurrentProject, + maxRight, } - currentProject.value = newCurrentProject } function setHasTasks(newHasTasks: boolean) {