feature: loading graph structure
This commit is contained in:
@@ -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[] {
|
||||
|
||||
Reference in New Issue
Block a user