From e1d43708c512a33d914cda7b4e5c5d7ccf8b1fde 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 03:59:54 +0000 Subject: [PATCH 1/3] feat: implement stale-while-revalidate for moderation lists to speed up initial load MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change optimizes the application startup by allowing the moderation system (AccessControl) to initialize immediately using cached data from localStorage if available. It triggers a background network refresh to update the lists asynchronously, preventing the UI from blocking on slow relay responses. Key changes: - Modified `js/accessControl.js` to make `ensureReady()` return immediately if hydrated from cache. - Updated `js/app.js` to use `ensureReady()` instead of the blocking `refresh()` during init. - Updated `js/ui/profileModalController.js` to conditionally show the "Fetching moderation filters…" status message only when waiting for network data. From 29857dc36cf85ef5647bef9e73e41c7d794dff83 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 04:21:13 +0000 Subject: [PATCH 2/3] Optimize application startup speed by parallelizing initialization --- js/accessControl.js | 24 +++++++++++------------- js/app.js | 15 +++++++++++++-- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/js/accessControl.js b/js/accessControl.js index 96dd35d8..3f9d7cd9 100644 --- a/js/accessControl.js +++ b/js/accessControl.js @@ -433,22 +433,20 @@ class AccessControl { } async ensureReady() { + // If not loaded and not already refreshing, kick off a background refresh. + // We do NOT await this promise, allowing the application to proceed immediately. + // Reactive updates (e.g. onBlacklistChange) will handle the UI state when data arrives. if (!this.hasLoaded && !this._isRefreshing) { - this.refresh(); + this.refresh().catch((error) => { + userLogger.warn( + "[accessControl] Background refresh failed:", + error, + ); + }); } - try { - await this._refreshPromise; - userLogger.info("[accessControl] ensureReady resolved"); - } catch (error) { - if (!this.hasLoaded) { - userLogger.warn("[accessControl] ensureReady retry"); - await this.refresh(); - await this._refreshPromise; - } else { - throw error; - } - } + // Always resolve immediately to prevent blocking application startup. + return Promise.resolve(); } whitelistMode() { diff --git a/js/app.js b/js/app.js index 6a1fa2d4..ca889f5a 100644 --- a/js/app.js +++ b/js/app.js @@ -436,9 +436,20 @@ class Application { profileModalPromise, ]); - const nostrInitPromise = nostrClient.init(); + // Initialize the pool early to unblock bootstrapTrustedSeeds, + // but do NOT await the full connection process here. + try { + await nostrClient.ensurePool(); + } catch (poolError) { + devLogger.warn("[app.init()] Pool ensure failed:", poolError); + } - await Promise.all([modalBootstrapPromise, nostrInitPromise]); + // Kick off relay connection in the background. + const nostrInitPromise = nostrClient.init().catch((err) => { + devLogger.warn("[app.init()] Background nostrClient.init failed:", err); + }); + + await modalBootstrapPromise; try { await bootstrapTrustedSeeds(); From ef34d3cf0246b194dfcfe96dde555b3f879c9e63 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 13:36:49 +0000 Subject: [PATCH 3/3] Optimize startup by non-blocking moderation and relay init --- js/app.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/js/app.js b/js/app.js index ca889f5a..acc7d99a 100644 --- a/js/app.js +++ b/js/app.js @@ -602,6 +602,21 @@ class Application { }); } + if (typeof accessControl.onWhitelistChange === "function") { + accessControl.onWhitelistChange(() => { + const refreshReason = "admin-whitelist-change"; + this.refreshAllVideoGrids({ + reason: refreshReason, + forceMainReload: true, + }).catch((error) => { + devLogger.warn( + "[app.init()] Failed to refresh video grids after admin whitelist change:", + error, + ); + }); + }); + } + // Grab the "Subscriptions" link by its id in the sidebar this.subscriptionsLink = document.getElementById("subscriptionsLink");