Skip to content

Commit 53f9f2c

Browse files
committed
fix: show windows when the app is rendered
Signed-off-by: Grigorii K. Shartsev <[email protected]>
1 parent 6d1d7a4 commit 53f9f2c

File tree

10 files changed

+41
-26
lines changed

10 files changed

+41
-26
lines changed

src/authentication/authentication.window.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const { BASE_TITLE, TITLE_BAR_HEIGHT } = require('../constants.js')
88
const { applyContextMenu } = require('../app/applyContextMenu.js')
99
const { getBrowserWindowIcon } = require('../shared/icons.utils.js')
1010
const { getAppConfig } = require('../app/AppConfig.ts')
11-
const { getScaledWindowSize } = require('../app/utils.ts')
11+
const { getScaledWindowSize, showWhenWindowMarkedReady } = require('../app/utils.ts')
1212

1313
/**
1414
* @return {import('electron').BrowserWindow}
@@ -53,6 +53,8 @@ function createAuthenticationWindow() {
5353

5454
window.loadURL(AUTHENTICATION_WINDOW_WEBPACK_ENTRY)
5555

56+
showWhenWindowMarkedReady(window)
57+
5658
return window
5759
}
5860

src/authentication/renderer/authentication.main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import '../../shared/assets/global.styles.css'
88
import Vue from 'vue'
99
import AuthenticationApp from './AuthenticationApp.vue'
1010
import { setupWebPage } from '../../shared/setupWebPage.js'
11+
import { markWindowReady } from '../../shared/markWindowReady.ts'
1112

1213
await setupWebPage()
1314

1415
new Vue(AuthenticationApp).$mount('#app')
16+
17+
markWindowReady()

src/help/help.window.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { BASE_TITLE } = require('../constants.js')
77
const { BrowserWindow } = require('electron')
88
const { applyExternalLinkHandler } = require('../app/externalLinkHandlers.js')
99
const { getBrowserWindowIcon } = require('../shared/icons.utils.js')
10-
const { getScaledWindowSize } = require('../app/utils.ts')
10+
const { getScaledWindowSize, showWhenWindowMarkedReady } = require('../app/utils.ts')
1111
const { applyContextMenu } = require('../app/applyContextMenu.js')
1212

1313
/**
@@ -44,9 +44,7 @@ function createHelpWindow(parentWindow) {
4444
applyExternalLinkHandler(window)
4545
applyContextMenu(window)
4646

47-
window.on('ready-to-show', () => {
48-
window.show()
49-
})
47+
showWhenWindowMarkedReady(window)
5048

5149
return window
5250
}

src/help/renderer/help.app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import './help.styles.css'
88

99
import Vue, { defineAsyncComponent } from 'vue'
1010
import { setupWebPage } from '../../shared/setupWebPage.js'
11+
import { markWindowReady } from '../../shared/markWindowReady.ts'
1112

1213
await setupWebPage()
1314

@@ -16,3 +17,5 @@ new Vue({
1617
name: 'HelpAppRoot',
1718
render: h => h(HelpApp),
1819
}).$mount('#app')
20+
21+
markWindowReady()

src/main.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const { installVueDevtools } = require('./install-vue-devtools.js')
2020
const { loadAppConfig, getAppConfig, setAppConfig } = require('./app/AppConfig.ts')
2121
const { triggerDownloadUrl } = require('./app/downloads.ts')
2222
const { 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
})

src/talk/renderer/talk.main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import './assets/overrides.css'
1111
import 'regenerator-runtime' // TODO: Why isn't it added on bundling
1212
import { initTalkHashIntegration } from './init.js'
1313
import { setupWebPage } from '../../shared/setupWebPage.js'
14+
import { markWindowReady } from '../../shared/markWindowReady.ts'
1415
import { createViewer } from './Viewer/Viewer.js'
1516
import { createDesktopApp } from './desktop.app.js'
1617
import { registerTalkDesktopSettingsSection } from './Settings/index.ts'
@@ -35,3 +36,5 @@ window.OCA.Talk.Desktop.talkRouter.value = window.OCA.Talk.instance.$router
3536
registerTalkDesktopSettingsSection()
3637

3738
await import('./notifications/notifications.store.js')
39+
40+
markWindowReady()

src/upgrade/renderer/upgrade.app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import '../../shared/assets/global.styles.css'
88
import Vue from 'vue'
99
import UpgradeApp from './UpgradeApp.vue'
1010
import { setupWebPage } from '../../shared/setupWebPage.js'
11+
import { markWindowReady } from '../../shared/markWindowReady.ts'
1112

1213
await setupWebPage()
1314

1415
new Vue(UpgradeApp).$mount('#app')
16+
17+
markWindowReady()

src/upgrade/upgrade.window.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { BASE_TITLE } = require('../constants.js')
77
const { BrowserWindow } = require('electron')
88
const { applyExternalLinkHandler } = require('../app/externalLinkHandlers.js')
99
const { getBrowserWindowIcon } = require('../shared/icons.utils.js')
10-
const { getScaledWindowSize } = require('../app/utils.ts')
10+
const { getScaledWindowSize, showWhenWindowMarkedReady } = require('../app/utils.ts')
1111

1212
/**
1313
*
@@ -38,9 +38,7 @@ function createUpgradeWindow() {
3838

3939
applyExternalLinkHandler(window)
4040

41-
window.on('ready-to-show', () => {
42-
window.show()
43-
})
41+
showWhenWindowMarkedReady(window)
4442

4543
return window
4644
}

src/welcome/welcome.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { appData } from '../app/AppData.js'
99
import { refetchAppDataIfDirty } from '../app/appData.service.js'
1010
import { initGlobals } from '../shared/globals/globals.js'
1111
import { applyAxiosInterceptors } from '../shared/setupWebPage.js'
12+
import { markWindowReady } from '../shared/markWindowReady.ts'
1213

1314
const quitButton = document.querySelector('.quit')
1415
quitButton.addEventListener('click', () => window.TALK_DESKTOP.quit())
@@ -20,6 +21,8 @@ window.TALK_DESKTOP.getSystemInfo().then(os => {
2021
}
2122
})
2223

24+
markWindowReady()
25+
2326
appData.restore()
2427

2528
initGlobals()

src/welcome/welcome.window.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
const { BrowserWindow } = require('electron')
77
const { getBrowserWindowIcon } = require('../shared/icons.utils.js')
88
const { isMac } = require('../app/system.utils.ts')
9-
const { getScaledWindowSize } = require('../app/utils.ts')
9+
const { getScaledWindowSize, showWhenWindowMarkedReady } = require('../app/utils.ts')
1010

1111
/**
1212
* @return {import('electron').BrowserWindow}
@@ -37,6 +37,8 @@ function createWelcomeWindow() {
3737

3838
window.loadURL(WELCOME_WINDOW_WEBPACK_ENTRY)
3939

40+
showWhenWindowMarkedReady(window)
41+
4042
return window
4143
}
4244

0 commit comments

Comments
 (0)