Skip to content

Commit 71bd4f2

Browse files
committed
chore: refactor to reuse configuration object
1 parent a5a0020 commit 71bd4f2

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

app.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,29 +125,32 @@ class ArcInit {
125125
}
126126
this.initConfig = initConfig;
127127
window.ArcConfig.initConfig = initConfig;
128-
await this.initApp();
129-
await this.upgradeApp();
128+
129+
let cnf;
130+
try {
131+
cnf = await this.prefProxy.load();
132+
await this._createApp(cnf);
133+
} catch (e) {
134+
this.reportFatalError(e);
135+
throw e;
136+
}
137+
138+
await this.initApp(cnf);
139+
await this.upgradeApp(cnf);
130140
await this.processInitialPath();
131141
await this.removeLoader();
132142
console.log('Application window is now ready.');
133143
}
134144
/**
135145
* Initialized the application when window is ready.
136146
*
147+
* @param {Object} cnf Current qapplication configuration
137148
* @return {Promise}
138149
*/
139-
async initApp() {
150+
async initApp(cnf) {
140151
// console.info('Initializing renderer window...');
141152
this.workspaceManager = new WorkspaceManager(this.initConfig.workspaceFile);
142153
this.workspaceManager.observe();
143-
let cnf;
144-
try {
145-
cnf = await this.prefProxy.load();
146-
await this._createApp(cnf);
147-
} catch (e) {
148-
this.reportFatalError(e);
149-
throw e;
150-
}
151154
if (this.initConfig.darkMode) {
152155
cnf.theme = '@advanced-rest-client/arc-electron-dark-theme';
153156
}
@@ -431,8 +434,7 @@ class ArcInit {
431434
}, 150);
432435
}
433436

434-
async upgradeApp() {
435-
const cnf = await this.prefProxy.load();
437+
async upgradeApp(cnf) {
436438
const inst = new UpgradeHelper(cnf.upgrades);
437439
const upgrades = inst.getUpgrades();
438440
if (!upgrades || upgrades.length === 0) {

0 commit comments

Comments
 (0)