From 0bc9a670d729f75fd653984aafdf0a37c67a2d8d Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 12 Apr 2024 17:56:19 +0200 Subject: [PATCH] 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 --- frontend/src/stores/projects.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/stores/projects.ts b/frontend/src/stores/projects.ts index 7c9bbbe1c..34a580a16 100644 --- a/frontend/src/stores/projects.ts +++ b/frontend/src/stores/projects.ts @@ -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, ] }