From 7e513f0d31b5632b3822543ec2a17e365b5b35ec Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Mon, 10 Mar 2025 15:40:58 +0300 Subject: [PATCH] return tags name --- src/space/services/space.service.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/space/services/space.service.ts b/src/space/services/space.service.ts index a8e166a..a3336e5 100644 --- a/src/space/services/space.service.ts +++ b/src/space/services/space.service.ts @@ -653,15 +653,9 @@ export class SpaceService { private buildSpaceHierarchy(spaces: SpaceEntity[]): SpaceEntity[] { const map = new Map(); - // Step 1: Create a map of spaces by UUID + // Step 1: Create a map of spaces by UUID, without creating new instances spaces.forEach((space) => { - map.set( - space.uuid, - this.spaceRepository.create({ - ...space, - children: [], // Add children if needed - }), - ); + map.set(space.uuid, space); // Use the existing space entity }); // Step 2: Organize the hierarchy @@ -669,9 +663,14 @@ export class SpaceService { spaces.forEach((space) => { if (space.parent && space.parent.uuid) { const parent = map.get(space.parent.uuid); - parent?.children?.push(map.get(space.uuid)); + if (parent) { + if (!parent.children) { + parent.children = []; + } + parent.children.push(space); + } } else { - rootSpaces.push(map.get(space.uuid)); + rootSpaces.push(space); } });