Fix Live Now not showing for non-streamer (#9773)
* Fix Live Now not showing for non-streamer * Rename for clarity * Logged out users too
This commit is contained in:
@@ -90,17 +90,27 @@ const DEFAULT_LIVE_ALLOWED_DOMAINS = [
|
||||
]
|
||||
export type LiveNowConfig = {
|
||||
allowedDomains: Set<string>
|
||||
allSupportedDomains: Set<string>
|
||||
}
|
||||
export function useLiveNowConfig(): LiveNowConfig {
|
||||
const ctx = useContext(LiveNowContext)
|
||||
const canGoLive = useCanGoLive()
|
||||
const {currentAccount} = useSession()
|
||||
if (!currentAccount?.did || !canGoLive) return {allowedDomains: new Set()}
|
||||
const allVipDomains = new Set(ctx.flatMap(live => live.domains))
|
||||
const allSupportedDomains = new Set(
|
||||
DEFAULT_LIVE_ALLOWED_DOMAINS.concat(Array.from(allVipDomains)),
|
||||
)
|
||||
if (!currentAccount?.did || !canGoLive)
|
||||
return {
|
||||
allowedDomains: new Set(),
|
||||
allSupportedDomains,
|
||||
}
|
||||
const vip = ctx.find(live => live.did === currentAccount.did)
|
||||
return {
|
||||
allowedDomains: new Set(
|
||||
DEFAULT_LIVE_ALLOWED_DOMAINS.concat(vip ? vip.domains : []),
|
||||
),
|
||||
allSupportedDomains,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user