diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index 2e3334f5e..15b0edcb2 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -113,16 +113,18 @@ export function TabsProvider({ children }: { children: ReactNode }) { } function refreshFlows() { - getTabsDataFromDB().then((DbData) => { - if (DbData && Object.keys(templates).length > 0) { - try { - processDBData(DbData); - updateStateWithDbData(DbData); - } catch (e) { - console.error(e); + setTimeout(() => { + getTabsDataFromDB().then((DbData) => { + if (DbData && Object.keys(templates).length > 0) { + try { + processDBData(DbData); + updateStateWithDbData(DbData); + } catch (e) { + console.error(e); + } } - } - }); + }); + }, 2000); } useEffect(() => { diff --git a/src/frontend/src/contexts/typesContext.tsx b/src/frontend/src/contexts/typesContext.tsx index 1ff3609e0..d8d3ca3ca 100644 --- a/src/frontend/src/contexts/typesContext.tsx +++ b/src/frontend/src/contexts/typesContext.tsx @@ -39,6 +39,9 @@ export function TypesProvider({ children }: { children: ReactNode }) { const { setLoading } = useContext(alertContext); useEffect(() => { + + setTimeout(() => { + // We will keep a flag to handle the case where the component is unmounted before the API call resolves. let isMounted = true; @@ -85,6 +88,8 @@ export function TypesProvider({ children }: { children: ReactNode }) { } getTypes(); + }, 2000); + }, []); function deleteNode(idx: string) {