feature: loading graph structure
This commit is contained in:
@@ -8,6 +8,7 @@ import NodeContextMenu from "./NodeContextMenu";
|
||||
import NodeRenameModal from "./NodeRenameModal";
|
||||
import { useGraphsStore } from "../stores/GraphsStore";
|
||||
import { useKeysdownStore, useSelectedNodesStore } from "../stores/ArrayStore";
|
||||
import { useLoadStore } from "../stores/LoadStore";
|
||||
|
||||
|
||||
export class GraphModel {
|
||||
@@ -85,6 +86,7 @@ export default function Graph({ setGraphPath }: { setGraphPath: React.Dispatch<R
|
||||
const isNodeSelected = useSelectedNodesStore(store => store.has);
|
||||
const anyNodeSelected = useSelectedNodesStore(store => store.hasAny);
|
||||
const deselectAllNodes = useSelectedNodesStore(store => store.clear);
|
||||
const loadCount = useLoadStore(state => state.loadCount);
|
||||
|
||||
useEffect(() => {
|
||||
setGraphPath(graphsPath);
|
||||
@@ -110,6 +112,18 @@ export default function Graph({ setGraphPath }: { setGraphPath: React.Dispatch<R
|
||||
}
|
||||
}, [nodeContext]);
|
||||
|
||||
useEffect(() => {
|
||||
if (loadCount === 0) return;
|
||||
const state = useGraphsStore.getState() as { graphsById: Map<string, GraphModel> };
|
||||
const mainGraph = state.graphsById.get('main');
|
||||
if (mainGraph) setGraph(mainGraph);
|
||||
selectGraphId('main');
|
||||
setGraphsPath([createPathSegment('main', 'Main')]);
|
||||
openNodeContext(null);
|
||||
openContextMenu(false);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [loadCount]);
|
||||
|
||||
useEffect(() => {
|
||||
if (nodeContext?.nodeId === graphId) {
|
||||
graphsPath.push(createPathSegment(nodeContext.nodeId, nodeContext.nodeName));
|
||||
|
||||
Reference in New Issue
Block a user