Add flow pool management functions to flowStore and remove duplicate functions from flowIOStore

This commit is contained in:
anovazzi1 2024-01-18 18:13:06 -03:00
commit 383152aa4b
3 changed files with 17 additions and 8 deletions

View file

@ -41,6 +41,20 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
inputTypes: [],
inputIds: [],
outputIds: [],
setFlowPool: (flowPool) => {
set({ flowPool });
},
addDataToFlowPool: (data: any, nodeId: string) => {
let newFlowPool = cloneDeep({ ...get().flowPool });
if (!newFlowPool[nodeId]) newFlowPool[nodeId] = [data];
else {
newFlowPool[nodeId].push(data);
}
get().setFlowPool(newFlowPool);
},
CleanFlowPool: () => {
get().setFlowPool({});
},
setPending: (isPending) => {
set({ isPending });
},

View file

@ -37,6 +37,9 @@ export type FlowStoreType = {
outputTypes: string[];
inputIds: string[];
outputIds: string[];
setFlowPool: (flowPool: FlowPoolType) => void;
addDataToFlowPool: (data: any, nodeId: string) => void;
CleanFlowPool: () => void;
updateSSEData: (sseData: object) => void;
sseData: object;
isBuilding: boolean;

View file

@ -23,19 +23,11 @@ export type FlowPoolType = {
};
export type flowIOStoreType = {
flowPool: FlowPoolType;
inputTypes: string[];
outputTypes: string[];
inputIds: string[];
outputIds: string[];
setFlowPool: (flowPool: FlowPoolType) => void;
setOutputTypes: (outputTypes: string[]) => void;
setInputTypes: (inputTypes: string[]) => void;
setInputIds: (inputIds: string[]) => void;
setOutputIds: (outputIds: string[]) => void;
updateFlowPoolNodes: (nodes: NodeType[]) => void;
addDataToFlowPool: (data: any, nodeId: string) => void;
CleanFlowPool: () => void;
checkInputandOutput: (flow?: FlowType) => boolean;
getInputTypes: (flow?: FlowType) => string[];
getOutputTypes: (flow?: FlowType) => string[];