diff --git a/src/frontend/src/controllers/API/index.ts b/src/frontend/src/controllers/API/index.ts index 73dd0f2e4..cd2d2f5fa 100644 --- a/src/frontend/src/controllers/API/index.ts +++ b/src/frontend/src/controllers/API/index.ts @@ -877,7 +877,7 @@ export async function getFlowPool({ }: { flowId: string; nodeId?: string; -}): Promise> { +}): Promise> { const config = {}; config["params"] = { flow_id: flowId }; if (nodeId) { diff --git a/src/frontend/src/modals/EditNodeModal/index.tsx b/src/frontend/src/modals/EditNodeModal/index.tsx index 817f48ea2..c89e34445 100644 --- a/src/frontend/src/modals/EditNodeModal/index.tsx +++ b/src/frontend/src/modals/EditNodeModal/index.tsx @@ -56,7 +56,6 @@ const EditNodeModal = forwardRef( ) => { const [myData, setMyData] = useState(data); - const setPending = useFlowStore((state) => state.setPending); const edges = useFlowStore((state) => state.edges); const setNode = useFlowStore((state) => state.setNode); @@ -546,7 +545,6 @@ const EditNodeModal = forwardRef( node: myData.node, }, })); - setPending(true); setOpen(false); }} type="submit" diff --git a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx index f25d688a8..fb81aa93b 100644 --- a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx @@ -69,7 +69,6 @@ export default function Page({ const takeSnapshot = useFlowsManagerStore((state) => state.takeSnapshot); const paste = useFlowStore((state) => state.paste); const resetFlow = useFlowStore((state) => state.resetFlow); - const setFlowPool = useFlowStore((state) => state.setFlowPool); const lastCopiedSelection = useFlowStore( (state) => state.lastCopiedSelection ); @@ -80,7 +79,6 @@ export default function Page({ const currentFlowId = useFlowsManagerStore((state) => state.currentFlowId); const setErrorData = useAlertStore((state) => state.setErrorData); const [selectionMenuVisible, setSelectionMenuVisible] = useState(false); - const [loading, setLoading] = useState(true); const edgeUpdateSuccessful = useRef(true); const position = useRef({ x: 0, y: 0 }); @@ -164,12 +162,8 @@ export default function Page({ edges: flow?.data?.edges ?? [], viewport: flow?.data?.viewport ?? { zoom: 1, x: 0, y: 0 }, }); - // getFlowPool({flowId: currentFlowId}).then((flowPool) => { - // setFlowPool(flowPool.data) - // setLoading(false) - // }) } - }, [currentFlowId, reactFlowInstance, setLoading, setFlowPool]); + }, [currentFlowId, reactFlowInstance]); useEffect(() => { return () => { diff --git a/src/frontend/src/stores/flowStore.ts b/src/frontend/src/stores/flowStore.ts index 447f68713..892f4ca56 100644 --- a/src/frontend/src/stores/flowStore.ts +++ b/src/frontend/src/stores/flowStore.ts @@ -9,7 +9,7 @@ import { applyNodeChanges, } from "reactflow"; import { create } from "zustand"; -import { updateFlowInDatabase } from "../controllers/API"; +import { getFlowPool, updateFlowInDatabase } from "../controllers/API"; import { NodeDataType, NodeType, @@ -35,7 +35,7 @@ const useFlowStore = create((set, get) => ({ nodes: [], edges: [], isBuilding: false, - isPending: false, + isPending: true, hasIO: false, reactFlowInstance: null, lastCopiedSelection: null, @@ -46,19 +46,12 @@ const useFlowStore = create((set, get) => ({ set({ flowPool }); }, addDataToFlowPool: (data: any, nodeId: string) => { - const currentFlow = useFlowsManagerStore.getState().currentFlow; let newFlowPool = cloneDeep({ ...get().flowPool }); if (!newFlowPool[nodeId]) newFlowPool[nodeId] = [data]; else { newFlowPool[nodeId].push(data); } get().setFlowPool(newFlowPool); - if (currentFlow) { - window.sessionStorage.setItem( - `${currentFlow!.id}`, - JSON.stringify(newFlowPool) - ); - } }, CleanFlowPool: () => { get().setFlowPool({}); @@ -68,12 +61,6 @@ const useFlowStore = create((set, get) => ({ }, resetFlow: ({ nodes, edges, viewport }) => { const currentFlow = useFlowsManagerStore.getState().currentFlow; - let flowPool = {}; - if (currentFlow) { - flowPool = JSON.parse( - window.sessionStorage.getItem(`${currentFlow!.id}`) ?? "{}" - ); - } let newEdges = cleanEdges(nodes, edges); const { inputs, outputs } = getInputsAndOutputs(nodes); set({ @@ -83,9 +70,13 @@ const useFlowStore = create((set, get) => ({ inputs, outputs, hasIO: inputs.length > 0 || outputs.length > 0, - flowPool, }); get().reactFlowInstance!.setViewport(viewport); + if (currentFlow) { + getFlowPool({ flowId: currentFlow.id }).then((flowPool) => { + set({ flowPool: flowPool.data.vertex_builds }); + }); + } }, setIsBuilding: (isBuilding) => { set({ isBuilding });