refactor(auth): remove dead AuthReset event
AuthReset was declared in the AuthEvent union and handled in auth-machine.idle.on with `assign(() => initialState)`, but nothing in the codebase actually dispatches it anymore. History of dispatch sites (now all gone): - sidebar-screen.tsx previously dispatched AuthReset post-logout alongside router.replace(ROUTES.chat) — that was simplified to just dispatch AuthLogoutSubmitted, the state machine's loggingOut state now does the context reset itself in onDone via the same `assign(() => initialState)` action. - chat-screen / splash / auth screens never dispatched it. - The /auth screen's pendingRedirect-based redirect loop doesn't need it (the redirect is one-shot, not a state that needs resetting). So the event handler is unreachable. Remove the type member from auth-events.ts and the handler from auth-machine.ts. No behavior change: the only path that 'reset auth state' was already covered by loggingOut.onDone. Verified via `grep -rn 'AuthReset' src/`: only 2 hits remain after this commit — both are the type declaration and the machine handler, which is now also gone (zero hits).
This commit is contained in:
@@ -12,7 +12,6 @@ export type AuthEvent =
|
|||||||
| { type: "AuthPanelModeChanged"; mode: AuthPanelMode }
|
| { type: "AuthPanelModeChanged"; mode: AuthPanelMode }
|
||||||
| { type: "AuthModeChanged"; mode: AuthMode }
|
| { type: "AuthModeChanged"; mode: AuthMode }
|
||||||
| { type: "AuthFormCleared" }
|
| { type: "AuthFormCleared" }
|
||||||
| { type: "AuthReset" }
|
|
||||||
| { type: "AuthLogoutSubmitted" }
|
| { type: "AuthLogoutSubmitted" }
|
||||||
/** App 启动时一次性派发 —— 读 storage 把 loginStatus 同步到状态机 */
|
/** App 启动时一次性派发 —— 读 storage 把 loginStatus 同步到状态机 */
|
||||||
| { type: "AuthInit" }
|
| { type: "AuthInit" }
|
||||||
|
|||||||
@@ -78,9 +78,6 @@ export const authMachine = setup({
|
|||||||
errorMessage: null,
|
errorMessage: null,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
AuthReset: {
|
|
||||||
actions: assign(() => initialState),
|
|
||||||
},
|
|
||||||
AuthLogoutSubmitted: "loggingOut",
|
AuthLogoutSubmitted: "loggingOut",
|
||||||
// 启动一次性 init:从 storage 同步 loginStatus 到状态机 —— 由 <AuthStatusChecker /> 派发
|
// 启动一次性 init:从 storage 同步 loginStatus 到状态机 —— 由 <AuthStatusChecker /> 派发
|
||||||
AuthInit: "initializing",
|
AuthInit: "initializing",
|
||||||
|
|||||||
Reference in New Issue
Block a user