From 20810988b0bde2d3cf7874b76221c68a9f4c1a19 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Tue, 27 Feb 2024 15:59:42 -0300 Subject: [PATCH] Add updateFlowPool function to FlowStoreType --- src/frontend/src/stores/flowStore.ts | 16 +++++++++++++++- src/frontend/src/types/zustand/flow/index.ts | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/stores/flowStore.ts b/src/frontend/src/stores/flowStore.ts index 300378406..7f0f88a5f 100644 --- a/src/frontend/src/stores/flowStore.ts +++ b/src/frontend/src/stores/flowStore.ts @@ -19,7 +19,7 @@ import { sourceHandleType, targetHandleType, } from "../types/flow"; -import { FlowStoreType } from "../types/zustand/flow"; +import { FlowPoolObjectType, FlowStoreType } from "../types/zustand/flow"; import { buildVertices } from "../utils/buildUtils"; import { cleanEdges, @@ -59,6 +59,20 @@ const useFlowStore = create((set, get) => ({ } get().setFlowPool(newFlowPool); }, + updateFlowPool:(nodeId:string,data:FlowPoolObjectType,buildId?:string)=>{ + let newFlowPool = cloneDeep({ ...get().flowPool }); + if (!newFlowPool[nodeId]){ + return; + } + else { + let index = newFlowPool[nodeId].length-1; + if(buildId){ + index = newFlowPool[nodeId].findIndex((flow)=>flow.id===buildId); + } + newFlowPool[nodeId][index] = data; + } + get().setFlowPool(newFlowPool); + }, CleanFlowPool: () => { get().setFlowPool({}); }, diff --git a/src/frontend/src/types/zustand/flow/index.ts b/src/frontend/src/types/zustand/flow/index.ts index cf6e786e0..01dbbf009 100644 --- a/src/frontend/src/types/zustand/flow/index.ts +++ b/src/frontend/src/types/zustand/flow/index.ts @@ -92,4 +92,5 @@ export type FlowStoreType = { updateBuildStatus: (nodeId: string[], status: BuildStatus) => void; revertBuiltStatusFromBuilding: () => void; flowBuildStatus: { [key: string]: BuildStatus }; + updateFlowPool: (nodeId:string, data:FlowPoolObjectType,buildId?:string) => void; };