Refactor Application.init into initialization phases

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-08 03:40:49 +00:00
1 parent 1fbee4219b
commit fa7a2997e8
1 file changed
+46 -24
+46 -24
View File
@@ -1208,36 +1208,58 @@ class Application {
await watchHistoryInitPromise;
}
async initializeServices() {
await this._initViewManager();
this._warmupNostrExtension();
this._initServiceWorker();
this._initAuthAndModeration();
}
initializeUIResources() {
return this._initModals();
}
async initializeNetwork() {
await this._initNostr();
}
async initializeDataAndSession() {
await this._initTrustedSeeds();
this._initViewCounter();
this._initAccessControl();
await this._initSessionActor();
this._initAccessControlListeners();
}
initializeUserInterface() {
this._initUI();
}
async performAutoLogin() {
await this._initAutoLogin();
}
async finalizeInitialization() {
this.setupEventListeners();
await this._initWatchHistory();
this.checkUrlParams();
}
async init() {
try {
await this._initViewManager();
this._warmupNostrExtension();
this._initServiceWorker();
this._initAuthAndModeration();
await this.initializeServices();
const modalBootstrapPromise = this._initModals();
const modalPromise = this.initializeUIResources();
await this.initializeNetwork();
await modalPromise;
await this._initNostr();
await this.initializeDataAndSession();
await modalBootstrapPromise;
await this._initTrustedSeeds();
this._initViewCounter();
this._initAccessControl();
await this._initSessionActor();
this._initAccessControlListeners();
this._initUI();
await this._initAutoLogin();
// 5. Setup general event listeners
this.setupEventListeners();
await this._initWatchHistory();
// 9. Check URL ?v= param
this.checkUrlParams();
this.initializeUserInterface();
await this.performAutoLogin();
await this.finalizeInitialization();
} catch (error) {
devLogger.error("Init failed:", error);
this.showError("Failed to connect to Nostr relay");