Browse Source

bug-fix

imwald
Silberengel 3 weeks ago
parent
commit
9593de22a3
  1. 33
      src/components/ReplyNoteList/index.tsx
  2. 8
      src/lib/relay-list-builder.ts
  3. 4
      src/services/client.service.ts

33
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 // Stream replies as relays return them (aggr is first in the list) instead of waiting for full EOSE.
// immediately, rather than waiting up to 10 s for all relays to EOSE. const streamThreadReply = (evt: NEvent) => {
const urlThreadRootInfo = rootInfo.type === 'I' ? rootInfo : null if (fetchGeneration !== replyFetchGenRef.current) return
const urlThreadOnevent = urlThreadRootInfo if (isPollVoteKind(evt)) return
? (evt: NEvent) => { if (rootInfo.type === 'I') {
if (fetchGeneration !== replyFetchGenRef.current) return if (!isRssArticleUrlThreadInteraction(evt, rootInfo.id)) return
if (isPollVoteKind(evt)) return }
if (!isRssArticleUrlThreadInteraction(evt, urlThreadRootInfo.id)) return if (shouldHideThreadResponseEvent(evt, mutePubkeySet, hideContentMentioningMutedUsers)) return
if (shouldHideThreadResponseEvent(evt, mutePubkeySet, hideContentMentioningMutedUsers)) addReplies([evt])
return if (!hasCache) setLoading(false)
addReplies([evt]) }
if (!hasCache) setLoading(false)
}
: undefined
// Use fetchEvents instead of subscribeTimeline for one-time fetching
const allReplies = await queryService.fetchEvents(relayUrlsForThreadReq, filters, { const allReplies = await queryService.fetchEvents(relayUrlsForThreadReq, filters, {
...(urlThreadOnevent ? { onevent: urlThreadOnevent } : {}), onevent: streamThreadReply,
foreground: statsForeground, foreground: true,
firstRelayResultGraceMs: 900,
globalTimeout: 12_000,
relayOpSource: 'ReplyNoteList.thread' relayOpSource: 'ReplyNoteList.thread'
}) })
@ -1112,7 +1110,6 @@ function ReplyNoteList({
// Filter and add replies (URL threads include kind 9802 highlights of this page) // Filter and add replies (URL threads include kind 9802 highlights of this page)
const regularReplies = allReplies.filter((evt) => { const regularReplies = allReplies.filter((evt) => {
if (isPollVoteKind(evt)) return false if (isPollVoteKind(evt)) return false
false
const match = replyMatchesThreadForList(evt, event, rootInfo, isDiscussionRoot, threadWalkFromBatch) const match = replyMatchesThreadForList(evt, event, rootInfo, isDiscussionRoot, threadWalkFromBatch)
if (!match) return false if (!match) return false
return !shouldHideThreadResponseEvent( return !shouldHideThreadResponseEvent(

8
src/lib/relay-list-builder.ts

@ -213,7 +213,7 @@ export async function buildComprehensiveRelayList(options: RelayListBuilderOptio
try { try {
const fav = const fav =
includeFavoriteRelays && userPubkey includeFavoriteRelays && userPubkey
? await client.fetchFavoriteRelays(userPubkey).catch(() => [] as string[]) ? await client.fetchFavoriteRelaysFromStorage(userPubkey).catch(() => [] as string[])
: [] : []
effectiveIncludeFastRead = viewerUsesGlobalRelayDefaults({ effectiveIncludeFastRead = viewerUsesGlobalRelayDefaults({
viewerPubkey: userPubkey, viewerPubkey: userPubkey,
@ -295,7 +295,7 @@ export async function buildComprehensiveRelayList(options: RelayListBuilderOptio
// Include favorite relays (kind 10012) if requested // Include favorite relays (kind 10012) if requested
if (includeFavoriteRelays) { if (includeFavoriteRelays) {
try { try {
const favoriteRelays = await client.fetchFavoriteRelays(userPubkey) const favoriteRelays = await client.fetchFavoriteRelaysFromStorage(userPubkey)
favoriteRelays.forEach((u) => { favoriteRelays.forEach((u) => {
trackPersonal(u) trackPersonal(u)
addRelay(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. // Menu / feed “favorite relays” (kind 10012) — same list as the sidebar; not part of NIP-65 alone.
if (includeFavoriteRelays) { if (includeFavoriteRelays) {
try { try {
const favoriteRelays = await client.fetchFavoriteRelays(userPubkey) const favoriteRelays = await client.fetchFavoriteRelaysFromStorage(userPubkey)
favoriteRelays.forEach((u) => { favoriteRelays.forEach((u) => {
trackPersonal(u) trackPersonal(u)
addRelay(u) addRelay(u)
@ -657,7 +657,7 @@ export async function buildReplyReadRelayList(
if (userPubkey) { if (userPubkey) {
try { try {
const [fav, rl] = await Promise.all([ const [fav, rl] = await Promise.all([
client.fetchFavoriteRelays(userPubkey).catch(() => [] as string[]), client.fetchFavoriteRelaysFromStorage(userPubkey).catch(() => [] as string[]),
client.peekRelayListFromStorage(userPubkey) client.peekRelayListFromStorage(userPubkey)
]) ])
useGlobal = viewerUsesGlobalRelayDefaults({ useGlobal = viewerUsesGlobalRelayDefaults({

4
src/services/client.service.ts

@ -719,8 +719,8 @@ class ClientService extends EventTarget {
return { all, httpIndexBases, cacheRelayEvent } return { all, httpIndexBases, cacheRelayEvent }
} }
/** Kind 10012 + embedded NIP-51 relay sets from IndexedDB only. */ /** Kind 10012 + embedded NIP-51 relay sets from IndexedDB only (no network). */
private async fetchFavoriteRelaysFromStorage(pubkey: string): Promise<string[]> { async fetchFavoriteRelaysFromStorage(pubkey: string): Promise<string[]> {
try { try {
const favoriteRelaysEvent = await indexedDb.getReplaceableEvent(pubkey, ExtendedKind.FAVORITE_RELAYS) const favoriteRelaysEvent = await indexedDb.getReplaceableEvent(pubkey, ExtendedKind.FAVORITE_RELAYS)
if (!favoriteRelaysEvent) return [] if (!favoriteRelaysEvent) return []

Loading…
Cancel
Save