From eb8b3c70ddd4104d3ee422b792de1aa3a2d4fb3c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 13 Jan 2026 15:25:03 +0000 Subject: [PATCH] Fix subscriptions loading issues and sidebar link visibility race condition. - Updated `shimLegacySimplePoolMethods` in `js/nostr/toolkit.js` to correctly handle `nostr-tools` v2 subscription closers (which are functions) in `unsub`. This prevents subscription leaks that were causing relays to reject new requests, leading to empty subscription lists. - Updated `bootstrapInterface` in `js/index.js` to await `applicationReadyPromise` before attempting to hydrate the sidebar navigation. This fixes a race condition where the sidebar "Subscriptions" link would remain hidden because the application auth state wasn't fully initialized when the sidebar was rendered. --- js/index.js | 6 ++++++ js/nostr/toolkit.js | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index 553d3e60..f74e90b6 100644 --- a/js/index.js +++ b/js/index.js @@ -621,6 +621,12 @@ async function bootstrapInterface() { await loadSidebar("components/sidebar.html", "sidebarContainer"); devLogger.log("Sidebar loaded."); + try { + await applicationReadyPromise; + } catch (error) { + // fall through + } + if (application && typeof application.hydrateSidebarNavigation === "function") { try { application.hydrateSidebarNavigation(); diff --git a/js/nostr/toolkit.js b/js/nostr/toolkit.js index 829be9c8..fd94b10b 100644 --- a/js/nostr/toolkit.js +++ b/js/nostr/toolkit.js @@ -522,7 +522,11 @@ export function shimLegacySimplePoolMethods(pool) { } closed = true; try { - closer?.close?.("closed by caller"); + if (typeof closer === "function") { + closer(); + } else if (closer && typeof closer.close === "function") { + closer.close("closed by caller"); + } } catch (error) { devLogger.warn("[nostr] Failed to close SimplePool subscription.", error); }