From 188ac2be0318a310b20935fb0bf6b92704e5131e Mon Sep 17 00:00:00 2001 From: Sanjeev Lakhwani Date: Wed, 31 Jul 2024 10:19:44 -0400 Subject: [PATCH] reorganized dispatch requests --- src/js/components/BentoAppRouter.tsx | 40 +++++++++------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/src/js/components/BentoAppRouter.tsx b/src/js/components/BentoAppRouter.tsx index c94eee59..67ab9e5d 100644 --- a/src/js/components/BentoAppRouter.tsx +++ b/src/js/components/BentoAppRouter.tsx @@ -26,33 +26,19 @@ const BentoAppRouter = () => { const isAuthenticated = useIsAuthenticated(); useEffect(() => { - const fetchInitialData = async () => { - try { - await Promise.all([dispatch(makeGetDataRequestThunk()), dispatch(makeGetSearchFields())]); - - const followUpPromises = [ - dispatch(makeGetConfigRequest()), - dispatch(populateClickable()), - dispatch(makeGetAboutRequest()), - dispatch(getBeaconConfig()), - dispatch(makeGetProvenanceRequest()), - dispatch(makeGetKatsuPublic()), - dispatch(fetchKatsuData()), - dispatch(fetchGohanData()), - dispatch(makeGetServiceInfoRequest()), - ]; - - if (isAuthenticated) { - followUpPromises.push(dispatch(makeGetDataTypes())); - } - - await Promise.all(followUpPromises); - } catch (error) { - console.error('Error fetching initial data', error); - } - }; - - fetchInitialData(); + dispatch(makeGetConfigRequest()).then(() => dispatch(getBeaconConfig())); + dispatch(makeGetAboutRequest()); + dispatch(makeGetDataRequestThunk()); + dispatch(makeGetSearchFields()).then(() => dispatch(populateClickable())); + dispatch(makeGetProvenanceRequest()); + dispatch(makeGetKatsuPublic()); + dispatch(fetchKatsuData()); + dispatch(fetchGohanData()); + dispatch(makeGetServiceInfoRequest()); + + if (isAuthenticated) { + dispatch(makeGetDataTypes()); + } }, [isAuthenticated]); if (isAutoAuthenticating) {