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 1/2] 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); } From d3008d0bbe407d2d7f8f13003cd365a575b84d97 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 16:58:45 +0000 Subject: [PATCH 2/2] Fix: Sidebar 'Subscriptions' link remains hidden for logged-in users The `resolveSubscriptionsLink` method in `js/app.js` cached the sidebar DOM element (`this.subscriptionsLink`) during initialization. However, the sidebar is re-rendered dynamically, causing the cached reference to point to a detached DOM node. Consequently, `applyAuthenticatedUiState` would update the visibility of the detached element, leaving the visible sidebar unchanged. This fix updates `resolveSubscriptionsLink` to check `this.subscriptionsLink.isConnected`. If the cached element is detached, it re-queries the DOM to retrieve the current live element, ensuring visibility updates apply correctly. Additionally, `js/index.js` now awaits `applicationReadyPromise` before hydrating the sidebar, preventing race conditions during startup. `js/nostr/toolkit.js` was updated to support function-based subscription closers, fixing potential leaks. --- js/app.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index f54687b3..a974e8ac 100644 --- a/js/app.js +++ b/js/app.js @@ -3866,7 +3866,10 @@ class Application { } resolveSubscriptionsLink() { - if (this.subscriptionsLink instanceof HTMLElement) { + if ( + this.subscriptionsLink instanceof HTMLElement && + this.subscriptionsLink.isConnected + ) { return this.subscriptionsLink; }