Bluesky app fork with some witchin' additions 💫

Fix Live Now not showing for non-streamer (#9773)

* Fix Live Now not showing for non-streamer

* Rename for clarity

* Logged out users too

authored by

Eric Bailey and committed by
GitHub
fd6b8fcb 2953b3a0

+20 -6
+7 -3
src/lib/actor-status.ts
··· 20 20 void tick // revalidate every minute 21 21 22 22 if (shadowed && 'status' in shadowed && shadowed.status) { 23 - const isValid = validateStatus(shadowed.status, config) 23 + const isValid = isStatusValidForViewers(shadowed.status, config) 24 24 const isDisabled = shadowed.status.isDisabled || false 25 25 const isActive = isStatusStillActive(shadowed.status.expiresAt) 26 26 if (isValid && !isDisabled && isActive) { ··· 64 64 return isAfter(expiry, now) 65 65 } 66 66 67 - export function validateStatus( 67 + /** 68 + * Validates whether the live status is valid for display in the app. Does NOT 69 + * validate if the status is valid for the acting user e.g. as they go live. 70 + */ 71 + export function isStatusValidForViewers( 68 72 status: AppBskyActorDefs.StatusView, 69 73 config: LiveNowConfig, 70 74 ) { ··· 72 76 try { 73 77 if (AppBskyEmbedExternal.isView(status.embed)) { 74 78 const url = new URL(status.embed.external.uri) 75 - return config.allowedDomains.has(url.hostname) 79 + return config.allSupportedDomains.has(url.hostname) 76 80 } else { 77 81 return false 78 82 }
+11 -1
src/state/service-config.tsx
··· 90 90 ] 91 91 export type LiveNowConfig = { 92 92 allowedDomains: Set<string> 93 + allSupportedDomains: Set<string> 93 94 } 94 95 export function useLiveNowConfig(): LiveNowConfig { 95 96 const ctx = useContext(LiveNowContext) 96 97 const canGoLive = useCanGoLive() 97 98 const {currentAccount} = useSession() 98 - if (!currentAccount?.did || !canGoLive) return {allowedDomains: new Set()} 99 + const allVipDomains = new Set(ctx.flatMap(live => live.domains)) 100 + const allSupportedDomains = new Set( 101 + DEFAULT_LIVE_ALLOWED_DOMAINS.concat(Array.from(allVipDomains)), 102 + ) 103 + if (!currentAccount?.did || !canGoLive) 104 + return { 105 + allowedDomains: new Set(), 106 + allSupportedDomains, 107 + } 99 108 const vip = ctx.find(live => live.did === currentAccount.did) 100 109 return { 101 110 allowedDomains: new Set( 102 111 DEFAULT_LIVE_ALLOWED_DOMAINS.concat(vip ? vip.domains : []), 103 112 ), 113 + allSupportedDomains, 104 114 } 105 115 } 106 116
+2 -2
src/view/com/posts/PostFeed.tsx
··· 27 27 import {useLingui} from '@lingui/react' 28 28 import {useQueryClient} from '@tanstack/react-query' 29 29 30 - import {isStatusStillActive, validateStatus} from '#/lib/actor-status' 30 + import {isStatusStillActive, isStatusValidForViewers} from '#/lib/actor-status' 31 31 import {DISCOVER_FEED_URI, KNOWN_SHUTDOWN_FEEDS} from '#/lib/constants' 32 32 import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender' 33 33 import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' ··· 948 948 const actor = post.author 949 949 if ( 950 950 actor.status && 951 - validateStatus(actor.status, liveNowConfig) && 951 + isStatusValidForViewers(actor.status, liveNowConfig) && 952 952 isStatusStillActive(actor.status.expiresAt) 953 953 ) { 954 954 if (!seenActorWithStatusRef.current.has(actor.did)) {