From 6cdaccc897e92b206489fdf74244c5120344cadc Mon Sep 17 00:00:00 2001 From: Shawn Chang Date: Wed, 28 Feb 2024 02:52:52 +0800 Subject: [PATCH] save/load added operation IDs --- .../src/components/GraphContainer.tsx | 5 +++++ .../src/states/GraphContainerState.ts | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/interactive-computational-graph/src/components/GraphContainer.tsx b/interactive-computational-graph/src/components/GraphContainer.tsx index 2a3c8b4..6276d0c 100644 --- a/interactive-computational-graph/src/components/GraphContainer.tsx +++ b/interactive-computational-graph/src/components/GraphContainer.tsx @@ -541,6 +541,7 @@ const GraphContainer: FunctionComponent = ({ nextNodeId, nodeNameBuilderState, nextOperationId, + operationIdsAddedAtLeastOnce: Array.from(operationIdsAddedAtLeastOnce), reactFlowState: reactFlowInstance.toObject(), }; }, [ @@ -550,6 +551,7 @@ const GraphContainer: FunctionComponent = ({ nextNodeId, nextOperationId, nodeNameBuilder, + operationIdsAddedAtLeastOnce, reactFlowInstance, saveFeatureOperations, ]); @@ -630,6 +632,9 @@ const GraphContainer: FunctionComponent = ({ setNextNodeId(graphContainerState.nextNodeId); nodeNameBuilder.load(graphContainerState.nodeNameBuilderState); setNextOperationId(graphContainerState.nextOperationId); + setOperationIdsAddedAtLeastOnce( + new Set(graphContainerState.operationIdsAddedAtLeastOnce), + ); loadReactFlow(graphContainerState.reactFlowState); }, [coreGraphAdapter, loadFeatureOperations, loadReactFlow, nodeNameBuilder], diff --git a/interactive-computational-graph/src/states/GraphContainerState.ts b/interactive-computational-graph/src/states/GraphContainerState.ts index db44579..ea4d1f5 100644 --- a/interactive-computational-graph/src/states/GraphContainerState.ts +++ b/interactive-computational-graph/src/states/GraphContainerState.ts @@ -3,7 +3,6 @@ import type FeatureOperationState from "./FeatureOperationState"; import type NodeNameBuilderState from "./NodeNameBuilderState"; interface GraphContainerState { - // TODO(sc420): Uncomment other states // Core graph coreGraphAdapterState: CoreGraphAdapterState; @@ -16,7 +15,7 @@ interface GraphContainerState { nextOperationId: number; // Feature panel states - // operationIdsAddedAtLeastOnce: Set; + operationIdsAddedAtLeastOnce: string[]; // React Flow states reactFlowState: object;