fix(auth): include OAuth backend-sync phase in isLoading derivation
The AuthState.isLoading derivation in auth-context.tsx covered the OAuth redirect phase (loadingOAuth) but NOT the backend-sync phase that runs after the OAuth callback returns (syncingGoogleBackend / syncingFacebookBackend). Any UI that read isLoading would incorrectly report "not loading" during the backend token-exchange round-trip. Add the two missing state.matches() lines so isLoading is true for the entire OAuth login window (button click → OAuth redirect → callback → backend sync). Note: in the current OAuth flow the user is on /chat during the sync phase (NextAuth redirected them there), so the splash/auth button is not actually visible to reflect the new true value. The fix is still correct because: - Conceptually aligned: any in-flight login op is "loading" - Defense in depth: future UI on /chat that consumes isLoading will get accurate feedback - Non-regression: only makes isLoading more permissive (true more often), never false-fires A visible /chat overlay during the sync phase would be a separate, larger change — noted in the planning doc but not in this commit.
This commit is contained in:
@@ -61,11 +61,14 @@ export function AuthProvider({ children }: AuthProviderProps) {
|
|||||||
password: state.context.password,
|
password: state.context.password,
|
||||||
username: state.context.username,
|
username: state.context.username,
|
||||||
confirmPassword: state.context.confirmPassword,
|
confirmPassword: state.context.confirmPassword,
|
||||||
// isLoading 覆盖邮箱登录 / 邮箱注册 / OAuth 跳转(NextAuth 重定向期间)/ 显式游客登录
|
// isLoading 覆盖邮箱登录 / 邮箱注册 / OAuth 跳转(NextAuth 重定向期间)/
|
||||||
|
// OAuth 回调后端 sync / 显式游客登录
|
||||||
isLoading:
|
isLoading:
|
||||||
state.matches("loadingEmailLogin") ||
|
state.matches("loadingEmailLogin") ||
|
||||||
state.matches("loadingEmailRegister") ||
|
state.matches("loadingEmailRegister") ||
|
||||||
state.matches("loadingOAuth") ||
|
state.matches("loadingOAuth") ||
|
||||||
|
state.matches("syncingGoogleBackend") ||
|
||||||
|
state.matches("syncingFacebookBackend") ||
|
||||||
state.matches("loadingGuestLogin"),
|
state.matches("loadingGuestLogin"),
|
||||||
errorMessage: state.context.errorMessage,
|
errorMessage: state.context.errorMessage,
|
||||||
loginStatus: state.context.loginStatus,
|
loginStatus: state.context.loginStatus,
|
||||||
|
|||||||
Reference in New Issue
Block a user