This commit is contained in:
Stephen Zhou
2026-04-02 17:02:59 +08:00
parent 09ca243f0d
commit d032e236ad

View File

@@ -3,7 +3,7 @@
import type { ReactNode } from 'react'
import Cookies from 'js-cookie'
import { parseAsBoolean, useQueryState } from 'nuqs'
import { useCallback, useEffect, useState } from 'react'
import { useCallback, useEffect } from 'react'
import {
EDUCATION_VERIFY_URL_SEARCHPARAMS_ACTION,
EDUCATION_VERIFYING_LOCALSTORAGE_ITEM,
@@ -29,7 +29,6 @@ export const AppInitializer = ({
'oauth_new_user',
parseAsBoolean.withOptions({ history: 'replace' }),
)
const [isReady, setIsReady] = useState(false)
const isSetupFinished = useCallback(async () => {
try {
const setUpStatus = await fetchSetupStatusWithCache()
@@ -87,11 +86,7 @@ export const AppInitializer = ({
const redirectUrl = resolvePostLoginRedirect()
if (redirectUrl) {
location.replace(redirectUrl)
return
}
// Initialization completed without redirects; safe to render children
setIsReady(true)
}
catch {
router.replace('/signin')
@@ -99,8 +94,5 @@ export const AppInitializer = ({
})()
}, [isSetupFinished, router, pathname, searchParams, oauthNewUser])
if (!isReady)
return null
return children
}