Skip to content

Commit

Permalink
Removed refreshFlows from Zustand store
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaseduoli committed Aug 21, 2024
1 parent 4bc69c7 commit d3baec1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 46 deletions.
45 changes: 0 additions & 45 deletions src/frontend/src/stores/flowsManagerStore.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { cloneDeep } from "lodash";
import { create } from "zustand";
import { readFlowsFromDatabase } from "../controllers/API";
import { FlowType } from "../types/flow";
import {
FlowsManagerStoreType,
UseUndoRedoOptions,
} from "../types/zustand/flowsManager";
import {
extractFieldsFromComponenents,
processFlows,
} from "../utils/reactflowUtils";
import useAlertStore from "./alertStore";
import useFlowStore from "./flowStore";
import { useFolderStore } from "./foldersStore";
import { useTypesStore } from "./typesStore";

const defaultOptions: UseUndoRedoOptions = {
maxHistorySize: 100,
Expand Down Expand Up @@ -53,43 +45,6 @@ const useFlowsManagerStore = create<FlowsManagerStoreType>((set, get) => ({
setSaveLoading: (saveLoading: boolean) => set({ saveLoading }),
isLoading: false,
setIsLoading: (isLoading: boolean) => set({ isLoading }),
refreshFlows: () => {
return new Promise<void>((resolve, reject) => {
const starterFolderId = useFolderStore.getState().starterProjectId;

readFlowsFromDatabase()
.then((dbData) => {
if (dbData) {
const { data, flows } = processFlows(dbData);
const examples = flows.filter(
(flow) => flow.folder_id === starterFolderId,
);
get().setExamples(examples);

const flowsWithoutStarterFolder = flows.filter(
(flow) => flow.folder_id !== starterFolderId,
);

get().setFlows(flowsWithoutStarterFolder);
useTypesStore.setState((state) => ({
data: { ...state.data, ["saved_components"]: data },
ComponentFields: extractFieldsFromComponenents({
...state.data,
["saved_components"]: data,
}),
}));
resolve();
}
})
.catch((e) => {
set({ isLoading: false });
useAlertStore.getState().setErrorData({
title: "Could not load flows from database",
});
reject(e);
});
});
},
takeSnapshot: () => {
const currentFlowId = get().currentFlowId;
// push the current graph to the past state
Expand Down
1 change: 0 additions & 1 deletion src/frontend/src/types/zustand/flowsManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export type FlowsManagerStoreType = {
setSaveLoading: (saveLoading: boolean) => void;
isLoading: boolean;
setIsLoading: (isLoading: boolean) => void;
refreshFlows: () => Promise<void>;
undo: () => void;
redo: () => void;
takeSnapshot: () => void;
Expand Down

0 comments on commit d3baec1

Please sign in to comment.