From e63ca6eee39ec658eab68b75276eef98debeb7c4 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 11 Jan 2026 22:13:36 +0000 Subject: [PATCH] Fix infinite spinner in Subscriptions tab by correcting method context in NostrService and improving error resilience. --- js/services/nostrService.js | 53 ++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/js/services/nostrService.js b/js/services/nostrService.js index 5c420515..c59c5694 100644 --- a/js/services/nostrService.js +++ b/js/services/nostrService.js @@ -157,6 +157,17 @@ function extractSnapshotPreview(message) { return sanitizeSnapshotPreview(selected || ""); } +function getActiveKey(video) { + if (video.videoRootId) { + return `ROOT:${video.videoRootId}`; + } + const dTag = video.tags?.find((t) => Array.isArray(t) && t[0] === "d"); + if (dTag && typeof dTag[1] === "string") { + return `${video.pubkey}:${dTag[1]}`; + } + return `LEGACY:${video.id}`; +} + function resolveDirectMessageRemotePubkey(message, actorPubkey = "") { const normalizedActor = normalizeHexPubkey(actorPubkey); @@ -1185,29 +1196,33 @@ export class NostrService { try { await Promise.all( this.nostrClient.relays.map(async (url) => { - const events = await this.nostrClient.pool.list([url], [filter]); - for (const evt of events) { - if (evt && evt.id) { - this.nostrClient.rawEvents.set(evt.id, evt); - } - const vid = convertEventToVideo(evt); - if (vid.invalid) { - invalidNotes.push({ id: vid.id, reason: vid.reason }); - } else { - if ( - this.nostrClient && - typeof this.nostrClient.applyRootCreatedAt === "function" - ) { - this.nostrClient.applyRootCreatedAt(vid); + try { + const events = await this.nostrClient.pool.list([url], [filter]); + for (const evt of events) { + if (evt && evt.id) { + this.nostrClient.rawEvents.set(evt.id, evt); } - const activeKey = getActiveKey(vid); - if (vid.deleted) { - this.recordTombstone(activeKey, vid.created_at); + const vid = convertEventToVideo(evt); + if (vid.invalid) { + invalidNotes.push({ id: vid.id, reason: vid.reason }); } else { - this.applyTombstoneGuard(vid); + if ( + this.nostrClient && + typeof this.nostrClient.applyRootCreatedAt === "function" + ) { + this.nostrClient.applyRootCreatedAt(vid); + } + const activeKey = getActiveKey(vid); + if (vid.deleted) { + this.nostrClient.recordTombstone(activeKey, vid.created_at); + } else { + this.nostrClient.applyTombstoneGuard(vid); + } + localAll.set(evt.id, vid); } - localAll.set(evt.id, vid); } + } catch (relayErr) { + // ignore relay failures } }) );