From f7629c28f486e3bdf507f7523847b06fddd1627b Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 28 Mar 2023 14:44:07 +0200 Subject: [PATCH] fix(projects): make sure the project hierarchy is properly updated when moving projects between parents --- src/stores/projects.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/stores/projects.ts b/src/stores/projects.ts index 765ba9e60..cc18592d0 100644 --- a/src/stores/projects.ts +++ b/src/stores/projects.ts @@ -72,7 +72,19 @@ export const useProjectStore = defineStore('project', () => { // if the project is a child project, we need to also set it in the parent if (project.parentProjectId) { const parent = projects.value[project.parentProjectId] - parent.childProjects = parent.childProjects?.map(p => p.id === project.id ? project : p) + let foundProject = false + parent.childProjects = parent.childProjects?.map(p => { + if(p.id === project.id) { + foundProject = true + return project + } + + return p + }) + // If we hit this, the project now has a new parent project which it did not have before + if (!foundProject) { + parent.childProjects.push(project) + } setProject(parent, false) } }