fix(web): lobby falls back to quiz UI below 3 players

Default game type stays "mixed", but while fewer than 3 players are connected
the lobby renders the quiz config only (Quiz highlighted, Mixed/Blindtest
disabled) instead of showing blindtest settings to a lone host. It switches
back to the stored type automatically once 3 players are present — no manual
click needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
AyoubBenziza 2026-06-10 14:51:19 +02:00
parent a2e3fae858
commit a2dc687ac0

View file

@ -68,16 +68,19 @@ export function LobbyView({ snapshot }: { snapshot: RoomSnapshot }) {
const totalTracks = snapshot.submissions.reduce((n, s) => n + s.count, 0) const totalTracks = snapshot.submissions.reduce((n, s) => n + s.count, 0)
const myCount = const myCount =
snapshot.submissions.find((s) => s.playerId === playerId)?.count ?? 0 snapshot.submissions.find((s) => s.playerId === playerId)?.count ?? 0
const showQuiz = gameType === "quiz" || gameType === "mixed"
const showBlindtest = gameType === "blindtest" || gameType === "mixed"
// Le blindtest exige au moins 3 joueurs connectés (DJ + 2 devineurs). // Le blindtest exige au moins 3 joueurs connectés (DJ + 2 devineurs).
const connectedCount = snapshot.players.filter((p) => p.connected).length const connectedCount = snapshot.players.filter((p) => p.connected).length
const blindtestAvailable = connectedCount >= 3 const blindtestAvailable = connectedCount >= 3
// Tant que le blindtest est indisponible, on retombe sur du quiz (sans
// toucher au réglage stocké) : repasse en mixte automatiquement à 3 joueurs.
const effectiveType: GameType = blindtestAvailable ? gameType : "quiz"
const showQuiz = effectiveType === "quiz" || effectiveType === "mixed"
const showBlindtest =
effectiveType === "blindtest" || effectiveType === "mixed"
const rounds = buildRounds(gameType, showQuiz ? count : 0, totalTracks) const rounds = buildRounds(effectiveType, showQuiz ? count : 0, totalTracks)
const canStart = const canStart = rounds.length > 0
rounds.length > 0 && (!showBlindtest || blindtestAvailable)
async function start() { async function start() {
setError(null) setError(null)
@ -130,7 +133,7 @@ export function LobbyView({ snapshot }: { snapshot: RoomSnapshot }) {
<Button <Button
key={t.value} key={t.value}
className="flex-1" className="flex-1"
variant={gameType === t.value ? "default" : "secondary"} variant={effectiveType === t.value ? "default" : "secondary"}
disabled={needsThree} disabled={needsThree}
title={needsThree ? "Blindtest : 3 joueurs minimum" : undefined} title={needsThree ? "Blindtest : 3 joueurs minimum" : undefined}
onClick={() => updateSettings({ gameType: t.value })} onClick={() => updateSettings({ gameType: t.value })}