mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-04 11:52:25 +00:00
Merge pull request #1198 from PR0M3TH3AN/stale-while-revalidate-moderation-13578942910948659410
feat: implement stale-while-revalidate for moderation lists
This commit is contained in:
2 files changed
+39
-15
No files matched your search
+11
-13
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
@@ -591,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");
|
||||
|
||||
|
||||
Reference in new issue
Block a user