fix(games): allow room creator to rejoin without error
Some checks failed
Deploy to Production / test (push) Failing after 34s
Some checks failed
Deploy to Production / test (push) Failing after 34s
The room creator was added as a player during createRoom, but when GameRoom mounted it sent JOIN_ROOM which failed with "Already in room", leaving the UI stuck on the loading spinner. Now treats duplicate joins as successful rejoins, which also fixes reconnection after page refresh. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,7 +46,7 @@ export class RoomManager {
|
|||||||
|
|
||||||
const plugin = gameRegistry.get(room.gameSlug)!;
|
const plugin = gameRegistry.get(room.gameSlug)!;
|
||||||
if (room.players.length >= plugin.maxPlayers) return { ok: false, error: "Room is full" };
|
if (room.players.length >= plugin.maxPlayers) return { ok: false, error: "Room is full" };
|
||||||
if (room.players.includes(playerId)) return { ok: false, error: "Already in room" };
|
if (room.players.includes(playerId)) return { ok: true, started: room.status === "playing" };
|
||||||
|
|
||||||
room.players.push(playerId);
|
room.players.push(playerId);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user