feature: loading graph structure

This commit is contained in:
2026-03-06 14:31:51 +01:00
parent dcdd4d621e
commit 0af50e165a
5 changed files with 112 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ export interface TreeStore {
tree: TreeDataNode[];
add: (childNode: NodeContext, parentNodeId: string | undefined) => void;
remove: (nodeId: string) => void;
reset: () => void;
}
export const useGraphLayersTreeStore = create<TreeStore>()((set) => ({
@@ -87,7 +88,13 @@ export const useGraphLayersTreeStore = create<TreeStore>()((set) => ({
parentIdByChildId: state.parentIdByChildId,
tree: createTree([...state.rootNodes], nodesFlatById)
}
})
}),
reset: () => set({
nodesFlatById: new Map<React.Key, TreeDataNode>(),
parentIdByChildId: new Map<React.Key, string>(),
rootNodes: [],
tree: [],
}),
}));
export function createTree(nodes: TreeDataNode[], nodesFlatById: Map<React.Key, TreeDataNode>): TreeDataNode[] {