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({ @@ -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({ @@ -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(

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

@ -213,7 +213,7 @@ export async function buildComprehensiveRelayList(options: RelayListBuilderOptio @@ -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 @@ -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 @@ -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( @@ -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({

4
src/services/client.service.ts

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

Loading…
Cancel
Save