diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index d126f5fa9..bb010a844 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -34,6 +34,7 @@ export default function App() { const setSuccessOpen = useAlertStore((state) => state.setSuccessOpen); const loading = useAlertStore((state) => state.loading); const [fetchError, setFetchError] = useState(false); + const isLoading = useFlowsManagerStore((state) => state.isLoading); // Initialize state variable for the list of alerts const [alertsList, setAlertsList] = useState< @@ -170,7 +171,7 @@ export default function App() { description={FETCH_ERROR_DESCRIPION} message={FETCH_ERROR_MESSAGE} > - ) : loading ? ( + ) : isLoading ? (
diff --git a/src/frontend/src/pages/MainPage/components/components/index.tsx b/src/frontend/src/pages/MainPage/components/components/index.tsx index 130cb9eba..f2e7e134b 100644 --- a/src/frontend/src/pages/MainPage/components/components/index.tsx +++ b/src/frontend/src/pages/MainPage/components/components/index.tsx @@ -94,12 +94,6 @@ export default function ComponentsComponent({ setPageSize(10); } - useEffect(() => { - setTimeout(() => { - setLoadingScreen(false); - }, 600); - }, []); - return (
- {!loadingScreen && data.length === 0 ? ( + {!isLoading && data.length === 0 ? (
@@ -136,7 +130,7 @@ export default function ComponentsComponent({
) : (
- {loadingScreen === false && data?.length > 0 ? ( + {isLoading === false && data?.length > 0 ? ( data?.map((item, idx) => ( { @@ -185,7 +179,7 @@ export default function ComponentsComponent({
)}
- {!loadingScreen && data.length > 0 && ( + {!isLoading && data.length > 0 && (
((set, get) => ({ if (dbData) { const { data, flows } = processFlows(dbData, false); get().setFlows(flows); - set({ isLoading: false }); useTypesStore.setState((state) => ({ data: { ...state.data, ["saved_components"]: data }, })); + set({ isLoading: false }); resolve(); } }) diff --git a/src/frontend/src/stores/typesStore.ts b/src/frontend/src/stores/typesStore.ts index b84887774..a04b4c11f 100644 --- a/src/frontend/src/stores/typesStore.ts +++ b/src/frontend/src/stores/typesStore.ts @@ -4,6 +4,7 @@ import { APIDataType } from "../types/api"; import { TypesStoreType } from "../types/zustand/types"; import { templatesGenerator, typesGenerator } from "../utils/reactflowUtils"; import useAlertStore from "./alertStore"; +import useFlowsManagerStore from "./flowsManagerStore"; export const useTypesStore = create((set, get) => ({ types: {}, @@ -11,6 +12,8 @@ export const useTypesStore = create((set, get) => ({ data: {}, getTypes: () => { return new Promise(async (resolve, reject) => { + const setLoading = useFlowsManagerStore.getState().setIsLoading; + setLoading(true); getAll() .then((response) => { const data = response.data; @@ -20,6 +23,7 @@ export const useTypesStore = create((set, get) => ({ data: { ...old.data, ...data }, templates: templatesGenerator(data), })); + setLoading(false) resolve(); }) .catch((error) => {