From 82938bdaac4a11599686ffe3129c3154cc57d420 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 27 Jan 2026 16:26:24 -0600 Subject: [PATCH] Memoize --- src/state/service-config.tsx | 38 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/state/service-config.tsx b/src/state/service-config.tsx index bc2fc43503..29fa6bec90 100644 --- a/src/state/service-config.tsx +++ b/src/state/service-config.tsx @@ -97,28 +97,30 @@ export function useLiveNowConfig(): LiveNowConfig { const ctx = useContext(LiveNowContext) const canGoLive = useCanGoLive() const {currentAccount} = useSession() - const defaultAllowedHosts = new Set(DEFAULT_LIVE_ALLOWED_DOMAINS) - const allowedHostsExceptionsByDid = new Map>() - for (const live of ctx) { - allowedHostsExceptionsByDid.set( - live.did, - new Set(DEFAULT_LIVE_ALLOWED_DOMAINS.concat(live.domains)), - ) - } - if (!currentAccount?.did || !canGoLive) + return useMemo(() => { + const defaultAllowedHosts = new Set(DEFAULT_LIVE_ALLOWED_DOMAINS) + const allowedHostsExceptionsByDid = new Map>() + for (const live of ctx) { + allowedHostsExceptionsByDid.set( + live.did, + new Set(DEFAULT_LIVE_ALLOWED_DOMAINS.concat(live.domains)), + ) + } + if (!currentAccount?.did || !canGoLive) + return { + currentAccountAllowedHosts: new Set(), + defaultAllowedHosts, + allowedHostsExceptionsByDid, + } + const vip = ctx.find(live => live.did === currentAccount.did) return { - currentAccountAllowedHosts: new Set(), + currentAccountAllowedHosts: new Set( + DEFAULT_LIVE_ALLOWED_DOMAINS.concat(vip ? vip.domains : []), + ), defaultAllowedHosts, allowedHostsExceptionsByDid, } - const vip = ctx.find(live => live.did === currentAccount.did) - return { - currentAccountAllowedHosts: new Set( - DEFAULT_LIVE_ALLOWED_DOMAINS.concat(vip ? vip.domains : []), - ), - defaultAllowedHosts, - allowedHostsExceptionsByDid, - } + }, [ctx, currentAccount, canGoLive]) } export function useCanGoLive() {