Fix host screen

This commit is contained in:
Joey Yakimowich-Payne 2026-01-25 08:05:57 -07:00
commit 5242f8d1f3
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
3 changed files with 44 additions and 8 deletions

View file

@ -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');
}