fix(project): set maxRight on projects after opening a task
continuous-integration/drone/push Build is failing Details

This commit is contained in:
kolaente 2023-06-21 15:09:31 +02:00
parent f55c42f124
commit 83c0ef4e8b
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 11 additions and 2 deletions

View File

@ -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) {