@@ -144,7 +144,7 @@ if (is.windows()) {
144144
145145ipcMain . handle ( 'get-main-plugin-names' , ( ) => Object . keys ( mainPlugins ) ) ;
146146
147- function loadPlugins ( win : BrowserWindow ) {
147+ async function loadPlugins ( win : BrowserWindow ) {
148148 injectCSS ( win . webContents , youtubeMusicCSS ) ;
149149 // Load user CSS
150150 const themes : string [ ] = config . get ( 'options.themes' ) ;
@@ -175,7 +175,7 @@ function loadPlugins(win: BrowserWindow) {
175175 console . log ( 'Loaded plugin - ' + plugin ) ;
176176 const handler = mainPlugins [ plugin as keyof typeof mainPlugins ] ;
177177 if ( handler ) {
178- handler ( win , options as never ) ;
178+ await handler ( win , options as never ) ;
179179 }
180180 }
181181 } catch ( e ) {
@@ -184,7 +184,7 @@ function loadPlugins(win: BrowserWindow) {
184184 }
185185}
186186
187- function createMainWindow ( ) {
187+ async function createMainWindow ( ) {
188188 const windowSize = config . get ( 'window-size' ) ;
189189 const windowMaximized = config . get ( 'window-maximized' ) ;
190190 const windowPosition : Electron . Point = config . get ( 'window-position' ) ;
@@ -223,7 +223,7 @@ function createMainWindow() {
223223 : 'default' ) ,
224224 autoHideMenuBar : config . get ( 'options.hideMenu' ) ,
225225 } ) ;
226- loadPlugins ( win ) ;
226+ await loadPlugins ( win ) ;
227227
228228 if ( windowPosition ) {
229229 const { x : windowX , y : windowY } = windowPosition ;
@@ -258,7 +258,6 @@ function createMainWindow() {
258258 const urlToLoad = config . get ( 'options.resumeOnStart' )
259259 ? config . get ( 'url' )
260260 : config . defaultConfig . url ;
261- win . webContents . loadURL ( urlToLoad ) ;
262261 win . on ( 'closed' , onClosed ) ;
263262
264263 type PiPOptions = typeof config . defaultConfig . plugins [ 'picture-in-picture' ] ;
@@ -338,6 +337,8 @@ function createMainWindow() {
338337
339338 removeContentSecurityPolicy ( ) ;
340339
340+ await win . webContents . loadURL ( urlToLoad ) ;
341+
341342 return win ;
342343}
343344
@@ -414,17 +415,17 @@ app.on('window-all-closed', () => {
414415 globalShortcut . unregisterAll ( ) ;
415416} ) ;
416417
417- app . on ( 'activate' , ( ) => {
418+ app . on ( 'activate' , async ( ) => {
418419 // On OS X it's common to re-create a window in the app when the
419420 // dock icon is clicked and there are no other windows open.
420421 if ( mainWindow === null ) {
421- mainWindow = createMainWindow ( ) ;
422+ mainWindow = await createMainWindow ( ) ;
422423 } else if ( ! mainWindow . isVisible ( ) ) {
423424 mainWindow . show ( ) ;
424425 }
425426} ) ;
426427
427- app . on ( 'ready' , ( ) => {
428+ app . on ( 'ready' , async ( ) => {
428429 if ( config . get ( 'options.autoResetAppCache' ) ) {
429430 // Clear cache after 20s
430431 const clearCacheTimeout = setTimeout ( ( ) => {
@@ -469,7 +470,7 @@ app.on('ready', () => {
469470 }
470471 }
471472
472- mainWindow = createMainWindow ( ) ;
473+ mainWindow = await createMainWindow ( ) ;
473474 setApplicationMenu ( mainWindow ) ;
474475 setUpTray ( app , mainWindow ) ;
475476
0 commit comments