Skip to content

Commit

Permalink
reorganized dispatch requests
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjeevLakhwani committed Jul 31, 2024
1 parent 5901e1a commit 188ac2b
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions src/js/components/BentoAppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 188ac2b

Please sign in to comment.