|
|
|
@ -1,7 +1,7 @@ |
|
|
|
import { FAST_READ_RELAY_URLS } from '@/constants' |
|
|
|
import { FAST_READ_RELAY_URLS } from '@/constants' |
|
|
|
import { feedRelayPolicyUrls } from '@/features/feed/relay-policy' |
|
|
|
import { feedRelayPolicyUrls } from '@/features/feed/relay-policy' |
|
|
|
import { getRelayListFromEvent, getHttpRelayListFromEvent } from '@/lib/event-metadata' |
|
|
|
import { getRelayListFromEvent, getHttpRelayListFromEvent } from '@/lib/event-metadata' |
|
|
|
import { buildAllFavoritesFeedRelayUrls } from '@/lib/home-feed-relays' |
|
|
|
import { buildAllFavoritesFeedRelayUrls, stripNostrLandAggrFromRelayUrls } from '@/lib/home-feed-relays' |
|
|
|
import logger from '@/lib/logger' |
|
|
|
import logger from '@/lib/logger' |
|
|
|
import { syncViewerRelayStackNostrLandAggrEligible } from '@/lib/nostr-land-relay-eligibility' |
|
|
|
import { syncViewerRelayStackNostrLandAggrEligible } from '@/lib/nostr-land-relay-eligibility' |
|
|
|
import { normalizeAnyRelayUrl } from '@/lib/url' |
|
|
|
import { normalizeAnyRelayUrl } from '@/lib/url' |
|
|
|
@ -29,7 +29,9 @@ function buildHomeReplyFeedRelayUrls( |
|
|
|
httpRelayUrls: string[], |
|
|
|
httpRelayUrls: string[], |
|
|
|
blockedRelays: string[] |
|
|
|
blockedRelays: string[] |
|
|
|
): string[] { |
|
|
|
): string[] { |
|
|
|
return feedRelayPolicyUrls( |
|
|
|
/** Home Replies/Gallery: never prepend aggr (reserved for side-panel threads, profiles, spells). */ |
|
|
|
|
|
|
|
return stripNostrLandAggrFromRelayUrls( |
|
|
|
|
|
|
|
feedRelayPolicyUrls( |
|
|
|
[ |
|
|
|
[ |
|
|
|
{ source: 'favorites', urls: primaryRelayUrls }, |
|
|
|
{ source: 'favorites', urls: primaryRelayUrls }, |
|
|
|
{ source: 'viewer-read', urls: inboxRelayUrls }, |
|
|
|
{ source: 'viewer-read', urls: inboxRelayUrls }, |
|
|
|
@ -39,10 +41,12 @@ function buildHomeReplyFeedRelayUrls( |
|
|
|
{ |
|
|
|
{ |
|
|
|
operation: 'read', |
|
|
|
operation: 'read', |
|
|
|
blockedRelays, |
|
|
|
blockedRelays, |
|
|
|
|
|
|
|
nostrLandAggr: 'never', |
|
|
|
applySocialKindBlockedFilter: false, |
|
|
|
applySocialKindBlockedFilter: false, |
|
|
|
allowThirdPartyLocalRelays: true |
|
|
|
allowThirdPartyLocalRelays: true |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function FeedProvider({ children }: { children: ReactNode }) { |
|
|
|
export function FeedProvider({ children }: { children: ReactNode }) { |
|
|
|
@ -60,18 +64,18 @@ export function FeedProvider({ children }: { children: ReactNode }) { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
const primaryExtraRelayUrls = useMemo(() => [buildWispTrendingNotesRelayUrl()], []) |
|
|
|
const primaryExtraRelayUrls = useMemo(() => [buildWispTrendingNotesRelayUrl()], []) |
|
|
|
|
|
|
|
|
|
|
|
/** Home Replies widen to relays that can surface inbox/reply context. */ |
|
|
|
/** Read-side layers merged into {@link replyRelayUrls}; {@link outboxRelayUrls} is only for aggr eligibility sync. */ |
|
|
|
const replyExtraRelayLayers = useMemo(() => { |
|
|
|
const replyExtraRelayLayers = useMemo(() => { |
|
|
|
const cacheRelayUrls: string[] = [] |
|
|
|
const cacheRelayUrls: string[] = [] |
|
|
|
if (cacheRelayListEvent) { |
|
|
|
if (cacheRelayListEvent) { |
|
|
|
const list = getRelayListFromEvent(cacheRelayListEvent, blockedRelays) |
|
|
|
const list = getRelayListFromEvent(cacheRelayListEvent, blockedRelays) |
|
|
|
cacheRelayUrls.push(...list.read, ...list.write) |
|
|
|
cacheRelayUrls.push(...list.read) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const httpRelayUrls: string[] = [...(relayList?.httpRead ?? []), ...(relayList?.httpWrite ?? [])] |
|
|
|
const httpRelayUrls: string[] = [...(relayList?.httpRead ?? [])] |
|
|
|
if (httpRelayListEvent) { |
|
|
|
if (httpRelayListEvent) { |
|
|
|
const list = getHttpRelayListFromEvent(httpRelayListEvent, blockedRelays) |
|
|
|
const list = getHttpRelayListFromEvent(httpRelayListEvent, blockedRelays) |
|
|
|
httpRelayUrls.push(...list.httpRead, ...list.httpWrite) |
|
|
|
httpRelayUrls.push(...list.httpRead) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
@ -106,7 +110,8 @@ export function FeedProvider({ children }: { children: ReactNode }) { |
|
|
|
[] |
|
|
|
[] |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const viewerNostrLandAggrEligible = useMemo(() => { |
|
|
|
/** Keeps {@link getViewerRelayStackNostrLandAggrEligible} in sync for non-home reads (threads, profiles, etc.). */ |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
const urls = [ |
|
|
|
const urls = [ |
|
|
|
...favoriteFeedRelayUrls, |
|
|
|
...favoriteFeedRelayUrls, |
|
|
|
...replyExtraRelayLayers.inboxRelayUrls, |
|
|
|
...replyExtraRelayLayers.inboxRelayUrls, |
|
|
|
@ -114,7 +119,7 @@ export function FeedProvider({ children }: { children: ReactNode }) { |
|
|
|
...replyExtraRelayLayers.cacheRelayUrls, |
|
|
|
...replyExtraRelayLayers.cacheRelayUrls, |
|
|
|
...replyExtraRelayLayers.httpRelayUrls |
|
|
|
...replyExtraRelayLayers.httpRelayUrls |
|
|
|
] |
|
|
|
] |
|
|
|
return syncViewerRelayStackNostrLandAggrEligible(urls) |
|
|
|
syncViewerRelayStackNostrLandAggrEligible(urls) |
|
|
|
}, [favoriteFeedRelayUrls, replyExtraRelayLayers]) |
|
|
|
}, [favoriteFeedRelayUrls, replyExtraRelayLayers]) |
|
|
|
|
|
|
|
|
|
|
|
const lastHomeFeedUrlLogRef = useRef({ primary: '', reply: '' }) |
|
|
|
const lastHomeFeedUrlLogRef = useRef({ primary: '', reply: '' }) |
|
|
|
@ -139,14 +144,7 @@ export function FeedProvider({ children }: { children: ReactNode }) { |
|
|
|
} |
|
|
|
} |
|
|
|
setUrlStateIfChanged(setRelayUrls, primaryRelays) |
|
|
|
setUrlStateIfChanged(setRelayUrls, primaryRelays) |
|
|
|
setUrlStateIfChanged(setReplyRelayUrls, replyRelays) |
|
|
|
setUrlStateIfChanged(setReplyRelayUrls, replyRelays) |
|
|
|
}, [ |
|
|
|
}, [favoriteFeedRelayUrls, blockedRelays, primaryExtraRelayUrls, replyExtraRelayLayers, setUrlStateIfChanged]) |
|
|
|
favoriteFeedRelayUrls, |
|
|
|
|
|
|
|
blockedRelays, |
|
|
|
|
|
|
|
primaryExtraRelayUrls, |
|
|
|
|
|
|
|
replyExtraRelayLayers, |
|
|
|
|
|
|
|
setUrlStateIfChanged, |
|
|
|
|
|
|
|
viewerNostrLandAggrEligible |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const favoriteRelaysIdentity = useMemo( |
|
|
|
const favoriteRelaysIdentity = useMemo( |
|
|
|
() => |
|
|
|
() => |
|
|
|
@ -170,7 +168,6 @@ export function FeedProvider({ children }: { children: ReactNode }) { |
|
|
|
() => |
|
|
|
() => |
|
|
|
[ |
|
|
|
[ |
|
|
|
...replyExtraRelayLayers.inboxRelayUrls, |
|
|
|
...replyExtraRelayLayers.inboxRelayUrls, |
|
|
|
...replyExtraRelayLayers.outboxRelayUrls, |
|
|
|
|
|
|
|
...replyExtraRelayLayers.cacheRelayUrls, |
|
|
|
...replyExtraRelayLayers.cacheRelayUrls, |
|
|
|
...replyExtraRelayLayers.httpRelayUrls |
|
|
|
...replyExtraRelayLayers.httpRelayUrls |
|
|
|
] |
|
|
|
] |
|
|
|
@ -191,7 +188,6 @@ export function FeedProvider({ children }: { children: ReactNode }) { |
|
|
|
relaySets.length, |
|
|
|
relaySets.length, |
|
|
|
favoriteFeedRelayUrls.length - favoriteRelays.length, |
|
|
|
favoriteFeedRelayUrls.length - favoriteRelays.length, |
|
|
|
replyExtraRelayLayers.inboxRelayUrls.length, |
|
|
|
replyExtraRelayLayers.inboxRelayUrls.length, |
|
|
|
replyExtraRelayLayers.outboxRelayUrls.length, |
|
|
|
|
|
|
|
replyExtraRelayLayers.cacheRelayUrls.length, |
|
|
|
replyExtraRelayLayers.cacheRelayUrls.length, |
|
|
|
replyExtraRelayLayers.httpRelayUrls.length, |
|
|
|
replyExtraRelayLayers.httpRelayUrls.length, |
|
|
|
blockedRelays.length |
|
|
|
blockedRelays.length |
|
|
|
@ -206,7 +202,6 @@ export function FeedProvider({ children }: { children: ReactNode }) { |
|
|
|
relaySets: relaySets.length, |
|
|
|
relaySets: relaySets.length, |
|
|
|
relaySetRelays: favoriteFeedRelayUrls.length - favoriteRelays.length, |
|
|
|
relaySetRelays: favoriteFeedRelayUrls.length - favoriteRelays.length, |
|
|
|
inboxRelays: replyExtraRelayLayers.inboxRelayUrls.length, |
|
|
|
inboxRelays: replyExtraRelayLayers.inboxRelayUrls.length, |
|
|
|
outboxRelays: replyExtraRelayLayers.outboxRelayUrls.length, |
|
|
|
|
|
|
|
cacheRelays: replyExtraRelayLayers.cacheRelayUrls.length, |
|
|
|
cacheRelays: replyExtraRelayLayers.cacheRelayUrls.length, |
|
|
|
httpRelays: replyExtraRelayLayers.httpRelayUrls.length, |
|
|
|
httpRelays: replyExtraRelayLayers.httpRelayUrls.length, |
|
|
|
blockedRelays: blockedRelays.length |
|
|
|
blockedRelays: blockedRelays.length |
|
|
|
|