Skip to content

Commit

Permalink
Ensure seeds don't change after tournament start Closes #2004
Browse files Browse the repository at this point in the history
  • Loading branch information
Sendouc committed Jan 23, 2025
1 parent 734eb46 commit c58000f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/features/tournament-bracket/routes/to.$id.brackets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
tournamentBracketsSubscribePage,
tournamentJoinPage,
} from "~/utils/urls";
import { updateTeamSeeds } from "../../tournament/queries/updateTeamSeeds.server";
import {
useBracketExpanded,
useTournament,
Expand Down Expand Up @@ -142,6 +143,17 @@ export const action: ActionFunction = async ({ params, request }) => {
bracket,
}),
);

// ensures autoseeding is disabled
const isAllSeedsPersisted = tournament.ctx.teams.every(
(team) => typeof team.seed === "number",
);
if (!isAllSeedsPersisted) {
updateTeamSeeds({
tournamentId: tournament.ctx.id,
teamIds: tournament.ctx.teams.map((team) => team.id),
});
}
})();

break;
Expand Down

0 comments on commit c58000f

Please sign in to comment.