@@ -20,6 +20,7 @@ const { installVueDevtools } = require('./install-vue-devtools.js')
2020const { loadAppConfig, getAppConfig, setAppConfig } = require ( './app/AppConfig.ts' )
2121const { triggerDownloadUrl } = require ( './app/downloads.ts' )
2222const { applyTheme } = require ( './app/theme.config.ts' )
23+ const { showWhenWindowMarkedReady, waitWindowMarkedReady } = require ( './app/utils.ts' )
2324
2425/**
2526 * Parse command line arguments
@@ -146,7 +147,7 @@ app.whenReady().then(async () => {
146147 // There is no window (possible on macOS) - create
147148 if ( ! mainWindow || mainWindow . isDestroyed ( ) ) {
148149 mainWindow = createMainWindow ( )
149- mainWindow . once ( 'ready-to-show' , ( ) => mainWindow . show ( ) )
150+ showWhenWindowMarkedReady ( mainWindow )
150151 return
151152 }
152153
@@ -235,7 +236,6 @@ app.whenReady().then(async () => {
235236
236237 mainWindow = createWelcomeWindow ( )
237238 createMainWindow = createWelcomeWindow
238- mainWindow . once ( 'ready-to-show' , ( ) => mainWindow . show ( ) )
239239
240240 ipcMain . once ( 'appData:receive' , async ( event , appData ) => {
241241 const welcomeWindow = mainWindow
@@ -256,14 +256,15 @@ app.whenReady().then(async () => {
256256 createMainWindow = createAuthenticationWindow
257257 }
258258
259- mainWindow . once ( 'ready-to-show' , ( ) => {
260- // Do not show the main window if it is the Talk Window opened in the background
261- const isTalkWindow = createMainWindow === createTalkWindow
262- if ( ! isTalkWindow || ! ARGUMENTS . openInBackground ) {
263- mainWindow . show ( )
264- }
265- welcomeWindow . close ( )
266- } )
259+ await waitWindowMarkedReady ( mainWindow )
260+
261+ welcomeWindow . close ( )
262+
263+ // Do not show the main window if it is the Talk Window opened in the background
264+ const isTalkWindow = createMainWindow === createTalkWindow
265+ if ( ! isTalkWindow || ! ARGUMENTS . openInBackground ) {
266+ mainWindow . show ( )
267+ }
267268 } )
268269
269270 let macDockBounceId
@@ -289,19 +290,18 @@ app.whenReady().then(async () => {
289290
290291 ipcMain . handle ( 'authentication:openLoginWebView' , async ( event , serverUrl ) => openLoginWebView ( mainWindow , serverUrl ) )
291292
292- ipcMain . handle ( 'authentication:login' , async ( ) => {
293+ ipcMain . handle ( 'authentication:login' , ( ) => {
293294 mainWindow . close ( )
294295 mainWindow = createTalkWindow ( )
295296 createMainWindow = createTalkWindow
296- mainWindow . once ( 'ready-to-show' , ( ) => mainWindow . show ( ) )
297+ showWhenWindowMarkedReady ( mainWindow )
297298 } )
298299
299- ipcMain . handle ( 'authentication:logout' , async ( event ) => {
300+ ipcMain . handle ( 'authentication:logout' , async ( ) => {
300301 if ( createMainWindow === createTalkWindow ) {
301302 await mainWindow . webContents . session . clearStorageData ( )
302303 const authenticationWindow = createAuthenticationWindow ( )
303304 createMainWindow = createAuthenticationWindow
304- authenticationWindow . once ( 'ready-to-show' , ( ) => authenticationWindow . show ( ) )
305305
306306 mainWindow . destroy ( )
307307 mainWindow = authenticationWindow
@@ -324,7 +324,7 @@ app.whenReady().then(async () => {
324324 isInWindowRelaunch = true
325325 mainWindow . destroy ( )
326326 mainWindow = createMainWindow ( )
327- mainWindow . once ( 'ready-to-show' , ( ) => mainWindow . show ( ) )
327+ showWhenWindowMarkedReady ( mainWindow )
328328 isInWindowRelaunch = false
329329 } )
330330
@@ -340,7 +340,7 @@ app.whenReady().then(async () => {
340340 // dock icon is clicked and there are no other windows open.
341341 // See window-all-closed event handler.
342342 mainWindow = createMainWindow ( )
343- mainWindow . once ( 'ready-to-show' , ( ) => mainWindow . show ( ) )
343+ showWhenWindowMarkedReady ( mainWindow )
344344 }
345345 } )
346346} )
0 commit comments