fix(task): do not crash when loading a task if parent projects are not loaded

Related to https://community.vikunja.io/t/vikunja-freezes/2246
Related to https://github.com/go-vikunja/vikunja/issues/233
This commit is contained in:
kolaente 2024-04-12 17:56:19 +02:00
parent a3e5e98c64
commit 0bc9a670d7
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 5 additions and 1 deletions

View File

@ -207,13 +207,17 @@ export const useProjectStore = defineStore('project', () => {
}
function getAncestors(project: IProject): IProject[] {
if (typeof project === 'undefined') {
return []
}
if (!project?.parentProjectId) {
return [project]
}
const parentProject = projects.value[project.parentProjectId]
return [
...getAncestors(parentProject),
...(parentProject ? getAncestors(parentProject) : []),
project,
]
}