refactor(chat): remove unused ChatScreenVisible and ChatScreenInvisible events

The screen-lifecycle events were dead code: the transitions in chat-machine
(idle <-> ready) had no caller behavior tied to them, and the dispatches
in chat-screen.tsx were the only senders. Drop the union members, both
state transitions, and the mount-effect dispatches.

The idle state remains declared as initial but is no longer reachable
at runtime; can be refactored in a follow-up.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-11 18:38:11 +08:00
parent ed4ccddae3
commit 4b356f58f2
3 changed files with 5 additions and 10 deletions
+2 -6
View File
@@ -8,7 +8,7 @@
* - **订阅 auth 状态机**loginStatus)——
* - 派生 isGuest / 驱动 WS 生命周期 / 驱动初次加载(按 loginStatus 选 ChatInit vs ChatLoadMoreHistory
* - 驱动历史加载
* - 屏幕生命周期事件(init / visible / invisible
* - 屏幕初始化(mount 时按 loginStatus 派初次加载
* - 配额告警监听(**仅**游客 —— "非游客无消息限制"业务事实)
* - WebSocket 生命周期管理(基于 auth 状态机的 loginStatus
* - 渲染骨架(背景 + 顶部栏 + 消息区 + 输入栏)
@@ -103,14 +103,10 @@ export function ChatScreen() {
const [quotaExhausted, setQuotaExhausted] = useState(false);
// ─────────────────────────────────────────────────────────────
// 屏幕生命周期 —— mount 时按 loginStatus 派初次加载
// mount 时按 loginStatus 派初次加载
// ─────────────────────────────────────────────────────────────
useEffect(() => {
chatDispatch({ type: "ChatScreenVisible" });
dispatchInitialLoad(authState.loginStatus, chatDispatch);
return () => {
chatDispatch({ type: "ChatScreenInvisible" });
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [chatDispatch]);
// 注:mount useEffect 故意**不**依赖 loginStatus —— 首次 mount 时机是固定的