MCPcopy Create free account
hub / github.com/AlexErrant/Pentive / IsModProvider

Function IsModProvider

hub/src/components/isModContext.tsx:6–17  ·  view source on GitHub ↗
(props: {
	moderators: string[] | undefined
	children: JSX.Element
})

Source from the content-addressed store, hash-verified

4const IsModContext = createContext<Accessor<boolean>>()
5
6export function IsModProvider(props: {
7 moderators: string[] | undefined
8 children: JSX.Element
9}) {
10 const userId = useUserIdContext()
11 const isMod = () => props.moderators?.includes(userId() as string) ?? false
12 return (
13 <IsModContext.Provider value={isMod}>
14 {props.children}
15 </IsModContext.Provider>
16 )
17}
18
19export function useIsModContext() {
20 const context = useContext(IsModContext)

Callers

nothing calls this directly

Calls 1

useUserIdContextFunction · 0.90

Tested by

no test coverage detected