mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-02 02:42:28 +00:00
Optimize application startup speed by parallelizing initialization
This commit is contained in:
1 parent
e1d43708c5
commit
29857dc36c
2 files changed
+24
-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() {
|
||||
|
||||
Reference in new issue
Block a user