Add updateFlowPool function to FlowStoreType
This commit is contained in:
parent
835a7f4e63
commit
20810988b0
2 changed files with 16 additions and 1 deletions
|
|
@ -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<FlowStoreType>((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({});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue