This commit is contained in:
Stephen Zhou 2026-04-02 17:02:59 +08:00
parent 09ca243f0d
commit d032e236ad
No known key found for this signature in database

View File

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