mirror of
https://github.com/tiennm99/noitu.git
synced 2026-10-13 04:15:16 +00:00
Move the join/resume/quick-match/leave state machine out of routes/online/+page.svelte into stores/room-session.svelte.js, modelled on bot-session.svelte.js: no DOM, no runes beyond $state, so the resume time-box is something Vitest can drive directly. The page keeps layout, timers and wiring; the store keeps what the player asked for. fix(web): time-box the resume latch and stop leaking a left room's session A stale resume token used to get silence from the server, leaving `resuming` stuck true and every button on the join form disabled with no way out but a reload. `resuming` now clears five seconds after the socket opens if nothing has answered by then, same as it already does on an explicit error (which also covers a server new enough to send `session_not_resumable` instead of staying quiet). leave() now calls forgetSession(), matching the page-teardown path: without it, deliberately leaving a room left the token behind, and the next load of /online tried to resume into the room the player had just walked out of. fix(web): retry cancelQueue, leave and lobby actions instead of dropping them send() returns false while the socket is down, and cancelQueue/leave ignored that return value while ready/start/kick only reported it as a dead-looking button. All five now hold the request and resend it once the socket reopens, the way join/create already do, via room-session's held-action slot. Lobby's "reconnecting" banner is now driven by that held action instead of a local flag that never noticed a background retry had succeeded. Also: the lobby's chat panel now reopens once a game ends (phase 'over') instead of staying folded for the rest of the room's life after the first game, since phase never actually revisits 'lobby' on its own.