ChatCodes revisited

This commit is contained in:
Kalle 2026-03-14 16:37:04 +02:00
parent e5d26eefab
commit e69a7bf6be
5 changed files with 7 additions and 5 deletions

View File

@ -1,6 +1,8 @@
import * as React from "react";
import type { ChatContextValue } from "./chat-provider-types";
// xxx: think how chats should expire in relation to chatCode getting returned from loaders etc.
export const ChatContext = React.createContext<ChatContextValue | null>(null);
export function useChatContext(): ChatContextValue | null {

View File

@ -29,7 +29,7 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
return {
post,
chatCode:
user.roles.includes("STAFF") && !participantIds.includes(user.id)
user.roles.includes("STAFF") || participantIds.includes(user.id)
? post.chatCode
: undefined,
anyUserPrefersNoScreen:

View File

@ -43,9 +43,8 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
})
: null,
rawReportedWeapons,
// xxx: as a safety measure, it'd be good to send chat code also when user is in the match
chatCode:
user?.roles.includes("STAFF") && !matchUsers.includes(user.id)
user?.roles.includes("STAFF") || (user && matchUsers.includes(user.id))
? match.chatCode
: null,
};

View File

@ -46,5 +46,6 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
},
lastUpdated: Date.now(),
streamsCount: (await cachedStreams()).length,
chatCode: ownGroup ? ownGroup.chatCode : null,
};
};

View File

@ -123,8 +123,8 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
endedEarly,
noScreen,
chatCode:
tournament.isOrganizerOrStreamer(user) &&
!match.players.some((p) => p.id === user?.id)
tournament.isOrganizerOrStreamer(user) ||
match.players.some((p) => p.id === user?.id)
? match.chatCode
: undefined,
};