Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Stephen Zhou 2026-03-20 11:01:56 +08:00 committed by GitHub
parent ddb833e9a1
commit f7ce52e212
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 1 deletions

View File

@ -3,7 +3,7 @@
import type { ReactNode } from 'react'
import Cookies from 'js-cookie'
import { parseAsBoolean, useQueryState } from 'nuqs'
import { useCallback, useEffect } from 'react'
import { useCallback, useEffect, useState } from 'react'
import {
EDUCATION_VERIFY_URL_SEARCHPARAMS_ACTION,
EDUCATION_VERIFYING_LOCALSTORAGE_ITEM,
@ -29,6 +29,7 @@ export const AppInitializer = ({
'oauth_new_user',
parseAsBoolean.withOptions({ history: 'replace' }),
)
const [isReady, setIsReady] = useState(false)
const isSetupFinished = useCallback(async () => {
try {
const setUpStatus = await fetchSetupStatusWithCache()
@ -86,7 +87,11 @@ 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')
@ -94,5 +99,8 @@ export const AppInitializer = ({
})()
}, [isSetupFinished, router, pathname, searchParams, oauthNewUser])
if (!isReady)
return null
return children
}