mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 12:52:26 +00:00
perf(feed): don't block fresh load on remote admin-list fetch
loadVideos awaited ensureAccessControlReady -> waitForReady -> _performRefresh
-> loadAdminState, which awaits a remote admin-list fetch. On a cold load that
waits for relays to connect (~5s) plus the fetch, stalling the feed ~10s before
any video renders. The cached admin state IS hydrated synchronously at
construction, but with markLoaded:false, so waitForReady blocked on a full
remote refresh even when a usable cache existed ("refresh fixes it").
ensureAccessControlReady now blocks only on a first-ever cold load WITH whitelist
mode (where showing non-whitelisted content before the whitelist arrives would be
wrong). In every other case — admin state hydrated from the localStorage cache,
already loaded, or blacklist-only mode — it kicks the refresh off in the
background (ensureReady) and renders immediately; the reactive
onWhitelist/onBlacklistChange handlers re-filter the grid once fresh lists land.
Adds accessControl.isHydrated() and a branching test
(nostr-service-access-control-ready.test.mjs).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
0c8a17e3cf
commit
122d806ad2
3 files changed
+87
-9
No files matched your search
@@ -460,6 +460,14 @@ class AccessControl {
|
||||
return this.whitelistEnabled;
|
||||
}
|
||||
|
||||
// True once we have usable lists to filter with — either a completed refresh
|
||||
// or admin state hydrated synchronously from the localStorage cache at
|
||||
// construction. Callers use this to avoid blocking the feed on a remote
|
||||
// refresh when cached lists already allow accurate canAccess() checks.
|
||||
isHydrated() {
|
||||
return this.hasLoaded === true || this._hydratedFromCache === true;
|
||||
}
|
||||
|
||||
isSuperAdmin(npub) {
|
||||
const normalized = normalizeNpub(npub);
|
||||
return normalized ? normalized === ADMIN_SUPER_NPUB : false;
|
||||
|
||||
Reference in new issue
Block a user