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; };