ChatCode stuff

This commit is contained in:
Kalle 2026-03-15 09:20:53 +02:00
parent 825e133be2
commit 98ed4244ca
2 changed files with 13 additions and 10 deletions

View File

@ -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,
};
};

View File

@ -32,8 +32,6 @@ export default function TournamentMatchPage() {
const tournament = useTournament();
const data = useLoaderData<typeof loader>();
// xxx: ensure tournament match chat can also be used before the match starts
React.useEffect(() => {
if (visibility !== "visible" || tournament.ctx.isFinalized) return;