fix: do not render page while examples are loading (#4768)

* Added check if examples load before loading all pages

* [autofix.ci] apply automated fixes

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Lucas Oliveira 2024-11-22 15:07:16 -03:00 committed by GitHub
commit f440552ee9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

View file

@ -26,6 +26,7 @@ export const useGetBasicExamplesQuery: useQueryFunctionType<
const queryResult = query(["useGetBasicExamplesQuery"], responseFn, {
...options,
retry: 3,
});
return queryResult;

View file

@ -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) {
@ -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 />}
</>
);
}