diff --git a/src/components/ReplyNoteList/index.tsx b/src/components/ReplyNoteList/index.tsx index 0b0fac71..fb752c74 100644 --- a/src/components/ReplyNoteList/index.tsx +++ b/src/components/ReplyNoteList/index.tsx @@ -1079,25 +1079,23 @@ function ReplyNoteList({ }) ) - // For URL threads: stream events as they arrive from each relay so replies appear - // immediately, rather than waiting up to 10 s for all relays to EOSE. - const urlThreadRootInfo = rootInfo.type === 'I' ? rootInfo : null - const urlThreadOnevent = urlThreadRootInfo - ? (evt: NEvent) => { - if (fetchGeneration !== replyFetchGenRef.current) return - if (isPollVoteKind(evt)) return - if (!isRssArticleUrlThreadInteraction(evt, urlThreadRootInfo.id)) return - if (shouldHideThreadResponseEvent(evt, mutePubkeySet, hideContentMentioningMutedUsers)) - return - addReplies([evt]) - if (!hasCache) setLoading(false) - } - : undefined + // Stream replies as relays return them (aggr is first in the list) instead of waiting for full EOSE. + const streamThreadReply = (evt: NEvent) => { + if (fetchGeneration !== replyFetchGenRef.current) return + if (isPollVoteKind(evt)) return + if (rootInfo.type === 'I') { + if (!isRssArticleUrlThreadInteraction(evt, rootInfo.id)) return + } + if (shouldHideThreadResponseEvent(evt, mutePubkeySet, hideContentMentioningMutedUsers)) return + addReplies([evt]) + if (!hasCache) setLoading(false) + } - // Use fetchEvents instead of subscribeTimeline for one-time fetching const allReplies = await queryService.fetchEvents(relayUrlsForThreadReq, filters, { - ...(urlThreadOnevent ? { onevent: urlThreadOnevent } : {}), - foreground: statsForeground, + onevent: streamThreadReply, + foreground: true, + firstRelayResultGraceMs: 900, + globalTimeout: 12_000, relayOpSource: 'ReplyNoteList.thread' }) @@ -1112,7 +1110,6 @@ function ReplyNoteList({ // Filter and add replies (URL threads include kind 9802 highlights of this page) const regularReplies = allReplies.filter((evt) => { if (isPollVoteKind(evt)) return false - false const match = replyMatchesThreadForList(evt, event, rootInfo, isDiscussionRoot, threadWalkFromBatch) if (!match) return false return !shouldHideThreadResponseEvent( diff --git a/src/lib/relay-list-builder.ts b/src/lib/relay-list-builder.ts index 4916d10e..f4cf8dfc 100644 --- a/src/lib/relay-list-builder.ts +++ b/src/lib/relay-list-builder.ts @@ -213,7 +213,7 @@ export async function buildComprehensiveRelayList(options: RelayListBuilderOptio try { const fav = includeFavoriteRelays && userPubkey - ? await client.fetchFavoriteRelays(userPubkey).catch(() => [] as string[]) + ? await client.fetchFavoriteRelaysFromStorage(userPubkey).catch(() => [] as string[]) : [] effectiveIncludeFastRead = viewerUsesGlobalRelayDefaults({ viewerPubkey: userPubkey, @@ -295,7 +295,7 @@ export async function buildComprehensiveRelayList(options: RelayListBuilderOptio // Include favorite relays (kind 10012) if requested if (includeFavoriteRelays) { try { - const favoriteRelays = await client.fetchFavoriteRelays(userPubkey) + const favoriteRelays = await client.fetchFavoriteRelaysFromStorage(userPubkey) favoriteRelays.forEach((u) => { trackPersonal(u) addRelay(u) @@ -330,7 +330,7 @@ export async function buildComprehensiveRelayList(options: RelayListBuilderOptio // Menu / feed “favorite relays” (kind 10012) — same list as the sidebar; not part of NIP-65 alone. if (includeFavoriteRelays) { try { - const favoriteRelays = await client.fetchFavoriteRelays(userPubkey) + const favoriteRelays = await client.fetchFavoriteRelaysFromStorage(userPubkey) favoriteRelays.forEach((u) => { trackPersonal(u) addRelay(u) @@ -657,7 +657,7 @@ export async function buildReplyReadRelayList( if (userPubkey) { try { const [fav, rl] = await Promise.all([ - client.fetchFavoriteRelays(userPubkey).catch(() => [] as string[]), + client.fetchFavoriteRelaysFromStorage(userPubkey).catch(() => [] as string[]), client.peekRelayListFromStorage(userPubkey) ]) useGlobal = viewerUsesGlobalRelayDefaults({ diff --git a/src/services/client.service.ts b/src/services/client.service.ts index 36982043..9251ee14 100644 --- a/src/services/client.service.ts +++ b/src/services/client.service.ts @@ -719,8 +719,8 @@ class ClientService extends EventTarget { return { all, httpIndexBases, cacheRelayEvent } } - /** Kind 10012 + embedded NIP-51 relay sets from IndexedDB only. */ - private async fetchFavoriteRelaysFromStorage(pubkey: string): Promise { + /** Kind 10012 + embedded NIP-51 relay sets from IndexedDB only (no network). */ + async fetchFavoriteRelaysFromStorage(pubkey: string): Promise { try { const favoriteRelaysEvent = await indexedDb.getReplaceableEvent(pubkey, ExtendedKind.FAVORITE_RELAYS) if (!favoriteRelaysEvent) return []