fix: display matches properly when using custom seeding, hide colors for infered bracket

This commit is contained in:
2026-04-15 13:11:51 -04:00
Unverified
parent 40bce14498
commit 8dfb4b9683

View File

@@ -331,7 +331,6 @@ export default function SpectatePage() {
send(cmd.getData("TOURNAMENT_DATA")); send(cmd.getData("TOURNAMENT_DATA"));
} }
} else if (msg.key === "TOURNAMENT_DATA" && msg.value) { } else if (msg.key === "TOURNAMENT_DATA" && msg.value) {
resetLiveGames();
setKnockoutRawData(msg.value); setKnockoutRawData(msg.value);
} }
break; break;
@@ -677,7 +676,7 @@ function BracketPlayerRow({
isActive, isActive,
}: { }: {
name: string | null; name: string | null;
playerColor: 1 | 2; playerColor: 1 | 2 | null;
isActive: boolean; isActive: boolean;
}) { }) {
const isRed = playerColor === 1; const isRed = playerColor === 1;
@@ -692,7 +691,7 @@ function BracketPlayerRow({
: "border-gray-700 bg-gray-900 text-gray-400" : "border-gray-700 bg-gray-900 text-gray-400"
}`} }`}
> >
{name && ( {name && playerColor !== null && (
<div <div
className={`h-3.5 w-3.5 shrink-0 rounded-full ${ className={`h-3.5 w-3.5 shrink-0 rounded-full ${
isRed ? "bg-red-500" : "bg-yellow-400" isRed ? "bg-red-500" : "bg-yellow-400"
@@ -732,6 +731,8 @@ function MatchSelectorCard({
const borderClass = const borderClass =
status === "completed" ? "border-green-700/80" : "border-gray-700"; status === "completed" ? "border-green-700/80" : "border-gray-700";
const Tag = canSelect ? "button" : "div"; const Tag = canSelect ? "button" : "div";
const showColors = player1 !== null && player2 !== null;
return ( return (
<Tag <Tag
@@ -752,12 +753,12 @@ function MatchSelectorCard({
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
<BracketPlayerRow <BracketPlayerRow
name={player1} name={player1}
playerColor={1} playerColor={showColors ? 1 : null}
isActive={currentTurnColor === 1} isActive={currentTurnColor === 1}
/> />
<BracketPlayerRow <BracketPlayerRow
name={player2} name={player2}
playerColor={2} playerColor={showColors ? 2 : null}
isActive={currentTurnColor === 2} isActive={currentTurnColor === 2}
/> />
<div className="flex items-center justify-between pt-1 text-xs"> <div className="flex items-center justify-between pt-1 text-xs">
@@ -856,20 +857,17 @@ function buildKnockoutBracket(
const nextRound = displayRounds[roundIndex + 1]; const nextRound = displayRounds[roundIndex + 1];
const nextRoundPlayer = nextRound?.players[matchIndex] ?? null; const nextRoundPlayer = nextRound?.players[matchIndex] ?? null;
const liveMatch = findLiveMatch(liveGameEntries, player1, player2); const liveMatch = findLiveMatch(liveGameEntries, player1, player2);
const isProjectedRound = Boolean(round.projected);
const hasKnownPlayers = Boolean(player1 && player2);
const hasAdvancedPastRound = const hasAdvancedPastRound =
roundIndex < rounds.length - 1 && roundIndex < rounds.length - 1 &&
!displayRounds[roundIndex + 1]?.projected; !displayRounds[roundIndex + 1]?.projected;
const inferredCompletedRealMatch = const hasExplicitResult = Boolean(liveMatch?.result);
!isProjectedRound && hasKnownPlayers && !liveMatch;
const winner = const winner =
nextRoundPlayer && nextRoundPlayer &&
(nextRoundPlayer === player1 || nextRoundPlayer === player2) (nextRoundPlayer === player1 || nextRoundPlayer === player2)
? nextRoundPlayer ? nextRoundPlayer
: resolveLiveWinner(liveMatch, tournamentWinner, player1, player2); : resolveLiveWinner(liveMatch, tournamentWinner, player1, player2);
const status = const status =
winner || hasAdvancedPastRound || inferredCompletedRealMatch hasExplicitResult || winner || hasAdvancedPastRound
? "completed" ? "completed"
: liveMatch : liveMatch
? "live" ? "live"