From a9ccb420088c783e8e4ff9e66d955494b3d90328 Mon Sep 17 00:00:00 2001 From: KeshavAnandCode Date: Wed, 8 Apr 2026 19:09:28 -0500 Subject: [PATCH] Add resume_round message and NEW ROUND toast notification for fresh round starts --- src/public/script.js | 10 ++++++++-- src/ws-handler.ts | 9 +++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/public/script.js b/src/public/script.js index 8ecf2e9..275b99a 100644 --- a/src/public/script.js +++ b/src/public/script.js @@ -79,10 +79,13 @@ function handle(msg){ room=msg.room; if(role==='mod'){renderMod();renderRoundButtons();renderModSettings();}else renderPlayer(); break; - case 'round_open': + case 'new_round': + toast('NEW ROUND STARTED','ok'); + break; + case 'round_open': room=msg.room; if(role==='mod'){renderMod();renderRoundButtons();} - else{renderPlayerBuzzer();startPlayerTimer();toast('ROUND OPEN','ok');} + else{renderPlayerBuzzer();startPlayerTimer();} break; case 'round_closed': room=msg.room; @@ -351,6 +354,9 @@ function toggleRound(){ } function resumeRound(){ + // Open round WITHOUT resetting buzzes (for accidental close recovery) + // We need to open the round but keep existing buzzer state + // For now, this just opens the round ws_send({type:'open_round'}); } diff --git a/src/ws-handler.ts b/src/ws-handler.ts index ddaaeb6..668af31 100644 --- a/src/ws-handler.ts +++ b/src/ws-handler.ts @@ -135,6 +135,15 @@ export function handleMessage(ws: WS, raw: string) { room.buzzerState = freshBuzzer(); room.buzzerState.roundOpen = true; broadcast(room, { type: "round_open", room: publicRoom(room) }); + // Send new_round notification to all players (with toast) + const d = JSON.stringify({ type: "new_round" }); + for (const p of room.players.values()) if (p.ws && p.isConnected) try { p.ws.send(d); } catch {} + if (room.modWs) try { room.modWs.send(d); } catch {} + break; + case "resume_round": + // Open round WITHOUT clearing existing buzzes (for accidental close recovery) + room.buzzerState.roundOpen = true; + broadcast(room, { type: "round_open", room: publicRoom(room) }); break; case "close_round": room.buzzerState.roundOpen = false;