@@ -144,7 +144,7 @@ if (is.windows()) {
144
144
145
145
ipcMain . handle ( 'get-main-plugin-names' , ( ) => Object . keys ( mainPlugins ) ) ;
146
146
147
- function loadPlugins ( win : BrowserWindow ) {
147
+ async function loadPlugins ( win : BrowserWindow ) {
148
148
injectCSS ( win . webContents , youtubeMusicCSS ) ;
149
149
// Load user CSS
150
150
const themes : string [ ] = config . get ( 'options.themes' ) ;
@@ -175,7 +175,7 @@ function loadPlugins(win: BrowserWindow) {
175
175
console . log ( 'Loaded plugin - ' + plugin ) ;
176
176
const handler = mainPlugins [ plugin as keyof typeof mainPlugins ] ;
177
177
if ( handler ) {
178
- handler ( win , options as never ) ;
178
+ await handler ( win , options as never ) ;
179
179
}
180
180
}
181
181
} catch ( e ) {
@@ -184,7 +184,7 @@ function loadPlugins(win: BrowserWindow) {
184
184
}
185
185
}
186
186
187
- function createMainWindow ( ) {
187
+ async function createMainWindow ( ) {
188
188
const windowSize = config . get ( 'window-size' ) ;
189
189
const windowMaximized = config . get ( 'window-maximized' ) ;
190
190
const windowPosition : Electron . Point = config . get ( 'window-position' ) ;
@@ -223,7 +223,7 @@ function createMainWindow() {
223
223
: 'default' ) ,
224
224
autoHideMenuBar : config . get ( 'options.hideMenu' ) ,
225
225
} ) ;
226
- loadPlugins ( win ) ;
226
+ await loadPlugins ( win ) ;
227
227
228
228
if ( windowPosition ) {
229
229
const { x : windowX , y : windowY } = windowPosition ;
@@ -258,7 +258,6 @@ function createMainWindow() {
258
258
const urlToLoad = config . get ( 'options.resumeOnStart' )
259
259
? config . get ( 'url' )
260
260
: config . defaultConfig . url ;
261
- win . webContents . loadURL ( urlToLoad ) ;
262
261
win . on ( 'closed' , onClosed ) ;
263
262
264
263
type PiPOptions = typeof config . defaultConfig . plugins [ 'picture-in-picture' ] ;
@@ -338,6 +337,8 @@ function createMainWindow() {
338
337
339
338
removeContentSecurityPolicy ( ) ;
340
339
340
+ await win . webContents . loadURL ( urlToLoad ) ;
341
+
341
342
return win ;
342
343
}
343
344
@@ -414,17 +415,17 @@ app.on('window-all-closed', () => {
414
415
globalShortcut . unregisterAll ( ) ;
415
416
} ) ;
416
417
417
- app . on ( 'activate' , ( ) => {
418
+ app . on ( 'activate' , async ( ) => {
418
419
// On OS X it's common to re-create a window in the app when the
419
420
// dock icon is clicked and there are no other windows open.
420
421
if ( mainWindow === null ) {
421
- mainWindow = createMainWindow ( ) ;
422
+ mainWindow = await createMainWindow ( ) ;
422
423
} else if ( ! mainWindow . isVisible ( ) ) {
423
424
mainWindow . show ( ) ;
424
425
}
425
426
} ) ;
426
427
427
- app . on ( 'ready' , ( ) => {
428
+ app . on ( 'ready' , async ( ) => {
428
429
if ( config . get ( 'options.autoResetAppCache' ) ) {
429
430
// Clear cache after 20s
430
431
const clearCacheTimeout = setTimeout ( ( ) => {
@@ -469,7 +470,7 @@ app.on('ready', () => {
469
470
}
470
471
}
471
472
472
- mainWindow = createMainWindow ( ) ;
473
+ mainWindow = await createMainWindow ( ) ;
473
474
setApplicationMenu ( mainWindow ) ;
474
475
setUpTray ( app , mainWindow ) ;
475
476
0 commit comments