({ children, guildId }: { guildId?: string, children: React.ReactNode })
| 13 | type FullGuildHook = FetchDataHookNotBehindGuard<FullGuild> |
| 14 | |
| 15 | export function FullGuildProvider({ children, guildId }: { guildId?: string, children: React.ReactNode }) { |
| 16 | const session = useSession() |
| 17 | |
| 18 | const fetch = useCallback(async () => { |
| 19 | if (!guildId) { |
| 20 | throw new Error("guildId not set") |
| 21 | } |
| 22 | |
| 23 | return await session.apiClient.getFullDiscordGuild(guildId); |
| 24 | }, [session, guildId]) |
| 25 | |
| 26 | if (!guildId || !session.user) { |
| 27 | return <>{children}</> |
| 28 | } |
| 29 | |
| 30 | return <FetchData |
| 31 | context={fullGuildContext} |
| 32 | loader={fetch} |
| 33 | debugName="full_guild" |
| 34 | > |
| 35 | {children} |
| 36 | </FetchData> |
| 37 | } |
| 38 | |
| 39 | export function useCurrentFullGuild(): FullGuildHook { |
| 40 | const fetchedData = useFetchedData(fullGuildContext) |
nothing calls this directly
no test coverage detected