From 98ed4244cab6d75807781410a7e6451c05cbec91 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 15 Mar 2026 09:20:53 +0200 Subject: [PATCH] ChatCode stuff --- .../loaders/to.$id.matches.$mid.server.ts | 21 ++++++++++++------- .../routes/to.$id.matches.$mid.tsx | 2 -- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/features/tournament-bracket/loaders/to.$id.matches.$mid.server.ts b/app/features/tournament-bracket/loaders/to.$id.matches.$mid.server.ts index affc6e129..3a017a0fa 100644 --- a/app/features/tournament-bracket/loaders/to.$id.matches.$mid.server.ts +++ b/app/features/tournament-bracket/loaders/to.$id.matches.$mid.server.ts @@ -101,7 +101,12 @@ export const loader = async ({ params }: LoaderFunctionArgs) => { }) : false; - if (match.chatCode && !matchIsOver) { + if ( + match.chatCode && + !matchIsOver && + match.opponentOne && + match.opponentTwo + ) { const playerIds = match.players.map((p) => p.id); const matchContext = tournament.matchContextNamesById(matchId); @@ -111,21 +116,21 @@ export const loader = async ({ params }: LoaderFunctionArgs) => { subtitle: tournament.ctx.name, url: tournamentMatchPage({ tournamentId, matchId }), participantUserIds: playerIds, - expiresAfter: { hours: 2 }, + expiresAfter: tournament.isLeagueDivision ? { days: 30 } : { hours: 2 }, }); } + const shouldSeeChat = + tournament.isOrganizerOrStreamer(user) || + match.players.some((p) => p.id === user?.id); + return { - match, + match: shouldSeeChat ? match : { ...match, chatCode: undefined }, results, mapList, matchIsOver, endedEarly, noScreen, - chatCode: - tournament.isOrganizerOrStreamer(user) || - match.players.some((p) => p.id === user?.id) - ? match.chatCode - : undefined, + chatCode: shouldSeeChat ? match.chatCode : undefined, }; }; diff --git a/app/features/tournament-bracket/routes/to.$id.matches.$mid.tsx b/app/features/tournament-bracket/routes/to.$id.matches.$mid.tsx index 9dc35c506..24cac1fe5 100644 --- a/app/features/tournament-bracket/routes/to.$id.matches.$mid.tsx +++ b/app/features/tournament-bracket/routes/to.$id.matches.$mid.tsx @@ -32,8 +32,6 @@ export default function TournamentMatchPage() { const tournament = useTournament(); const data = useLoaderData(); - // xxx: ensure tournament match chat can also be used before the match starts - React.useEffect(() => { if (visibility !== "visible" || tournament.ctx.isFinalized) return;