Add setInactiveNodes function to FlowStore

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-02-22 23:39:13 -03:00
commit bd2767b1a5
2 changed files with 14 additions and 0 deletions

View file

@ -376,6 +376,14 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
const setErrorData = useAlertStore.getState().setErrorData;
const setNoticeData = useAlertStore.getState().setNoticeData;
function handleBuildUpdate(data: any) {
const responseData = data.data[data.id];
// responseData MAY contain inactive_vertices or it
// may be null, so we need to check for it
if (responseData && responseData.inactive_vertices) {
useFlowStore
.getState()
.setInactiveNodes(responseData.inactive_vertices);
}
get().addDataToFlowPool(data.data[data.id], data.id);
useFlowStore.getState().updateBuildStatus([data.id], BuildStatus.BUILT);
}
@ -431,6 +439,10 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
set({ verticesBuild: vertices });
},
verticesBuild: [],
setInactiveNodes(newState) {
set({ inactiveNodes: newState });
},
inactiveNodes: [],
}));
export default useFlowStore;

View file

@ -89,4 +89,6 @@ export type FlowStoreType = {
updateBuildStatus: (nodeId: string[], status: BuildStatus) => void;
updateVerticesBuild: (vertices: string[]) => void;
verticesBuild: string[];
inactiveNodes: string[];
setInactiveNodes: (newState: string[]) => void;
};