return tags name

This commit is contained in:
faris Aljohari
2025-03-10 15:40:58 +03:00
parent f6d47d0e39
commit 7e513f0d31

View File

@ -653,15 +653,9 @@ export class SpaceService {
private buildSpaceHierarchy(spaces: SpaceEntity[]): SpaceEntity[] {
const map = new Map<string, SpaceEntity>();
// 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);
}
});