Skip to content

Commit

Permalink
fix: do not render page while examples are loading (langflow-ai#4768)
Browse files Browse the repository at this point in the history
* Added check if examples load before loading all pages

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and diogocabral committed Nov 26, 2024
1 parent f1adfd3 commit 676ff57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const useGetBasicExamplesQuery: useQueryFunctionType<

const queryResult = query(["useGetBasicExamplesQuery"], responseFn, {
...options,
retry: 3,
});

return queryResult;
Expand Down
15 changes: 10 additions & 5 deletions src/frontend/src/pages/AppInitPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ export function AppInitPage() {
useGetConfig({ enabled: isFetched });
const { isFetched: typesLoaded } = useGetTypes({ enabled: isFetched });
useGetGlobalVariables({ enabled: typesLoaded });
useGetBasicExamplesQuery({ enabled: typesLoaded });
useGetTagsQuery({ enabled: typesLoaded });

useGetFoldersQuery({ enabled: typesLoaded });
useGetFoldersQuery({
enabled: typesLoaded,
});
const { isFetched: isExamplesFetched } = useGetBasicExamplesQuery({
enabled: typesLoaded,
});

useEffect(() => {
if (isFetched) {
Expand All @@ -49,11 +52,13 @@ export function AppInitPage() {
//need parent component with width and height
<>
{isLoaded ? (
(isLoading || !isFetched || !typesLoaded) && <LoadingPage overlay />
(isLoading || !isFetched || !isExamplesFetched || !typesLoaded) && (
<LoadingPage overlay />
)
) : (
<CustomLoadingPage />
)}
{isFetched && typesLoaded && <Outlet />}
{isFetched && isExamplesFetched && typesLoaded && <Outlet />}
</>
);
}

0 comments on commit 676ff57

Please sign in to comment.