Skip to content

Commit bf6275e

Browse files
GilbNclaude
andcommitted
Fix stale isSolo flag leaking into subsequent host/client sessions
After a solo session was disconnected, roomState.isSolo remained true because clearRoomState() only clears localStorage, and solo mode has no SocketHost whose destroy() would reset the store. Starting a hosted room afterwards then used SocketHost._syncRoomState's spread update, which preserved the stale isSolo flag — causing LobbyView/TimerView to keep showing the solo badge instead of the room code. - SocketHost._syncRoomState now explicitly sets isSolo/isSpectator to false so a host session can never inherit stale flags. - Disconnect handlers in LobbyView, TimerView, and DisplayView now reset the roomState store alongside clearRoomState(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d08abf5 commit bf6275e

4 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/lib/peer/SocketHost.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ export class SocketHost {
248248
...s,
249249
code: this.code,
250250
isHost: true,
251+
isSolo: false,
252+
isSpectator: false,
251253
connectedPeers: peers,
252254
}))
253255
if (this._onPeersChange) this._onPeersChange(peers)

src/views/DisplayView.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
}
6767
clearTimerState()
6868
clearRoomState()
69+
roomState.set({ code: null, isHost: false, isSpectator: false, isSolo: false, connectedPeers: [] })
6970
currentView.set('home')
7071
}
7172
</script>

src/views/LobbyView.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
window.__nsfHost = null
5656
}
5757
clearRoomState()
58+
roomState.set({ code: null, isHost: false, isSpectator: false, isSolo: false, connectedPeers: [] })
5859
currentView.set('home')
5960
}
6061
</script>

src/views/TimerView.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
}
175175
clearTimerState()
176176
clearRoomState()
177+
roomState.set({ code: null, isHost: false, isSpectator: false, isSolo: false, connectedPeers: [] })
177178
currentView.set('home')
178179
}
179180
</script>

0 commit comments

Comments
 (0)