@@ -20,6 +20,7 @@ import useAuthStore from "@/stores/authStore";
2020export function AppInitPage ( ) {
2121 const isAuthenticated = useAuthStore ( ( state ) => state . isAuthenticated ) ;
2222 const { pathname } = useLocation ( ) ;
23+ const isClerkAuth = IS_CLERK_AUTH ;
2324
2425 const refreshStars = useDarkStore ( ( state ) => state . refreshStars ) ;
2526 const refreshDiscordCount = useDarkStore ( ( state ) => state . refreshDiscordCount ) ;
@@ -35,27 +36,28 @@ export function AppInitPage() {
3536
3637 // Skip the initialization queries when unauthenticated visitors load the
3738 // unauthenticated marketing landing page rendered at the root route.
38- const skipAppInit = ! isAuthenticated && pathname === "/" ;
39+ const skipAppInit = ! isAuthenticated && pathname === "/" ;
40+ const waitForClerkAuth = isClerkAuth && ! isAuthenticated ;
3941
40- const shouldSkipAutoLogin = IS_CLERK_AUTH ;
42+ const shouldSkipAutoLogin = isClerkAuth ;
4143
4244 const { isFetched : isAutoLoginFetched , refetch : refetchAutoLogin } = useGetAutoLogin ( {
43- enabled : ! shouldSkipAutoLogin && isLoaded && ! shouldSkip && ! skipAppInit ,
45+ enabled : ! shouldSkipAutoLogin && isLoaded && ! shouldSkip && ! skipAppInit && ! waitForClerkAuth ,
4446 } ) ;
4547
4648 const isFetched = shouldSkipAutoLogin ? true : isAutoLoginFetched ;
4749
4850 const { isFetched : isConfigFetched } = useGetConfig ( {
49- enabled : isFetched && ! shouldSkip && ! skipAppInit ,
51+ enabled : isFetched && ! shouldSkip && ! skipAppInit && ! waitForClerkAuth ,
5052 } ) ;
5153
52- useGetVersionQuery ( { enabled : isFetched && ! shouldSkip && ! skipAppInit } ) ;
53- useGetGlobalVariables ( { enabled : isFetched && ! shouldSkip && ! skipAppInit } ) ;
54- useGetTagsQuery ( { enabled : isFetched && ! shouldSkip && ! skipAppInit } ) ;
55- useGetFoldersQuery ( { enabled : isFetched && ! shouldSkip && ! skipAppInit } ) ;
54+ useGetVersionQuery ( { enabled : isFetched && ! shouldSkip && ! skipAppInit && ! waitForClerkAuth } ) ;
55+ useGetGlobalVariables ( { enabled : isFetched && ! shouldSkip && ! skipAppInit && ! waitForClerkAuth } ) ;
56+ useGetTagsQuery ( { enabled : isFetched && ! shouldSkip && ! skipAppInit && ! waitForClerkAuth } ) ;
57+ useGetFoldersQuery ( { enabled : isFetched && ! shouldSkip && ! skipAppInit && ! waitForClerkAuth } ) ;
5658
5759 const { isFetched : isExamplesFetched , refetch : refetchExamples } = useGetBasicExamplesQuery ( {
58- enabled : ! shouldSkip && ! skipAppInit ,
60+ enabled : ! shouldSkip && ! skipAppInit && ! waitForClerkAuth ,
5961 } ) ;
6062
6163 useEffect ( ( ) => {
@@ -67,16 +69,22 @@ export function AppInitPage() {
6769 refreshDiscordCount ( ) ;
6870 }
6971
70- if ( isConfigFetched && ! shouldSkip ) {
71- refetchAutoLogin ( ) ;
72+ if ( isConfigFetched && ! shouldSkip && ! waitForClerkAuth ) {
73+ if ( ! shouldSkipAutoLogin ) {
74+ refetchAutoLogin ( ) ;
75+ }
7276 refetchExamples ( ) ;
7377 }
74- } , [ isFetched , isConfigFetched , shouldSkip , skipAppInit ] ) ;
78+ } , [ isFetched , isConfigFetched , shouldSkip , skipAppInit , waitForClerkAuth ] ) ;
7579
7680 if ( skipAppInit ) {
7781 return < Outlet /> ;
7882 }
7983
84+ if ( waitForClerkAuth ) {
85+ return < CustomLoadingPage /> ;
86+ }
87+
8088 return (
8189 //need parent component with width and height
8290 < >
0 commit comments