From 5242f8d1f341fa31ed957bf16bbc4e9083c451ee Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Sun, 25 Jan 2026 08:05:57 -0700 Subject: [PATCH] Fix host screen --- App.tsx | 1 + components/RevealScreen.tsx | 32 ++++++++++++++++++++++++++------ hooks/useGame.ts | 19 +++++++++++++++++-- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/App.tsx b/App.tsx index 270be7b..bf7a69f 100644 --- a/App.tsx +++ b/App.tsx @@ -299,6 +299,7 @@ function App() { onNext={showScoreboard} isPresenter={currentPlayerId === presenterId} onPresenterAdvance={() => sendAdvance('SCOREBOARD')} + hostParticipates={gameConfig.hostParticipates} /> ) : currentPlayerName ? ( void; isPresenter?: boolean; onPresenterAdvance?: () => void; + hostParticipates?: boolean; } export const RevealScreen: React.FC = ({ @@ -49,10 +50,13 @@ export const RevealScreen: React.FC = ({ role, onNext, isPresenter = false, - onPresenterAdvance + onPresenterAdvance, + hostParticipates = false }) => { const isHost = role === 'HOST'; const canAdvance = isHost || isPresenter; + // When host is participating, show client-style feedback view instead of presentation view + const showPlayerFeedback = !isHost || hostParticipates; // Trigger confetti for correct answers useEffect(() => { @@ -66,7 +70,8 @@ export const RevealScreen: React.FC = ({ } }, [isCorrect, isHost]); - if (isHost) { + // Host spectating (not participating) - show presentation view with big answer card + if (isHost && !hostParticipates) { const ShapeIcon = SHAPES[correctOption.shape]; const colorClass = COLORS[correctOption.color]; @@ -196,7 +201,7 @@ export const RevealScreen: React.FC = ({ {!isCorrect && ( -
+
= ({
)} - {isPresenter && onPresenterAdvance && ( + {/* Host participating gets the continue button */} + {isHost && onNext && ( + + Continue to Scoreboard + + + )} + + {/* Presenter (non-host) gets the continue button */} + {!isHost && isPresenter && onPresenterAdvance && ( Continue to Scoreboard - + )}
diff --git a/hooks/useGame.ts b/hooks/useGame.ts index a5a66b6..03bd3b7 100644 --- a/hooks/useGame.ts +++ b/hooks/useGame.ts @@ -544,11 +544,26 @@ export const useGame = (defaultGameConfig?: GameConfig) => { await updateHostPeerId(session.pin, session.hostSecret!, peerId); } - if (hostData.gameState === 'LOBBY') { + // Determine which state to restore to + const savedState = hostData.gameState; + const restoredPlayers = hostData.players || []; + const allAnswered = restoredPlayers.length > 0 && restoredPlayers.every((p: Player) => p.lastAnswerCorrect !== null); + + if (savedState === 'LOBBY') { setGameState('LOBBY'); - } else if (hostData.gameState === 'PODIUM') { + } else if (savedState === 'PODIUM') { setGameState('PODIUM'); + } else if (savedState === 'REVEAL') { + // Go directly to reveal screen - players may have already seen their results + setGameState('REVEAL'); + } else if (savedState === 'SCOREBOARD') { + // Go directly to scoreboard + setGameState('SCOREBOARD'); + } else if (savedState === 'QUESTION' && allAnswered) { + // All players answered while host was disconnected - go directly to reveal + setGameState('REVEAL'); } else { + // For QUESTION or COUNTDOWN states where not everyone answered, show HOST_RECONNECTED to let them resume setGameState('HOST_RECONNECTED'); }