mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-05 20:56:13 -05:00
ChatCodes revisited
This commit is contained in:
parent
e5d26eefab
commit
e69a7bf6be
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,5 +46,6 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
|
|||
},
|
||||
lastUpdated: Date.now(),
|
||||
streamsCount: (await cachedStreams()).length,
|
||||
chatCode: ownGroup ? ownGroup.chatCode : null,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user