From ad5b69514ce9b76bb54929c41d2c5df8a22cad76 Mon Sep 17 00:00:00 2001 From: danny Date: Sun, 14 Jun 2026 14:54:40 +0200 Subject: [PATCH] Fix renderHost crash (roundActive used before declaration) + reset state on lobby join --- index.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 030e1a3..c952789 100644 --- a/index.html +++ b/index.html @@ -701,7 +701,7 @@ const App = (() => { const d=await api('host_open',{code,pass}); role='host'; room=d.state.code; hostPass=pass; selectedImposters=new Set(d.state.liarKeys||[]); - questionsLoaded=false; + questionsLoaded=false; lastJSON=''; lastChatLen=0; lastRoundNum=-1; sessionStorage.setItem('bsb_session',JSON.stringify({role:'host',room:d.state.code,pass})); show('lobby',false); show('playerView',false); show('hostView',true); $('hRoom').textContent=room; @@ -715,6 +715,7 @@ const App = (() => { try{ const d=await api('player_join',{code,name:nm}); role='player'; room=d.state.code; pkey=d.pkey; name=nm; + lastJSON=''; lastChatLen=0; lastRoundNum=-1; localVotes=new Set(); sessionStorage.setItem('bsb_session',JSON.stringify({role:'player',room:d.state.code,pkey:d.pkey,name:nm})); show('lobby',false); show('hostView',false); show('playerView',true); $('pRoom').textContent=room; $('pName').textContent=nm; @@ -1206,6 +1207,8 @@ const App = (() => { const revealedKeys=state.revealedKeys||[]; const anyRevealed=state.revealed||ri>=9999||revealedKeys.length>0; const revealCount=ri>=9999?players.length:revealedKeys.length; + // Must be defined before use in renderImposterList + const roundActive=!!(state.normalQuestion); $('hRound').textContent=state.roundNum||1; $('hRoundState').textContent=anyRevealed?(revealCount>=players.length&&players.length>0?'aufgedeckt':`${revealCount}/${players.length} aufgedeckt`):'verdeckt'; renderHostPlayers(players); @@ -1222,8 +1225,7 @@ const App = (() => { questionsLoaded=true; } - // Question locking: disable textareas when a round is active - const roundActive=!!(state.normalQuestion); + // Question locking: disable textareas when a round is active (roundActive already defined above) $('hNormalQ').disabled=roundActive; $('hImposterQ').disabled=roundActive; $('hNormalQ').style.opacity=roundActive?'0.5':'1';