Skip to content

Commit

Permalink
fix: show windows when the app is rendered
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <[email protected]>
  • Loading branch information
ShGKme committed Nov 25, 2024
1 parent 6d1d7a4 commit 53f9f2c
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 26 deletions.
4 changes: 3 additions & 1 deletion src/authentication/authentication.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { BASE_TITLE, TITLE_BAR_HEIGHT } = require('../constants.js')
const { applyContextMenu } = require('../app/applyContextMenu.js')
const { getBrowserWindowIcon } = require('../shared/icons.utils.js')
const { getAppConfig } = require('../app/AppConfig.ts')
const { getScaledWindowSize } = require('../app/utils.ts')
const { getScaledWindowSize, showWhenWindowMarkedReady } = require('../app/utils.ts')

/**
* @return {import('electron').BrowserWindow}
Expand Down Expand Up @@ -53,6 +53,8 @@ function createAuthenticationWindow() {

window.loadURL(AUTHENTICATION_WINDOW_WEBPACK_ENTRY)

showWhenWindowMarkedReady(window)

return window
}

Expand Down
3 changes: 3 additions & 0 deletions src/authentication/renderer/authentication.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import '../../shared/assets/global.styles.css'
import Vue from 'vue'
import AuthenticationApp from './AuthenticationApp.vue'
import { setupWebPage } from '../../shared/setupWebPage.js'
import { markWindowReady } from '../../shared/markWindowReady.ts'

await setupWebPage()

new Vue(AuthenticationApp).$mount('#app')

markWindowReady()
6 changes: 2 additions & 4 deletions src/help/help.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { BASE_TITLE } = require('../constants.js')
const { BrowserWindow } = require('electron')
const { applyExternalLinkHandler } = require('../app/externalLinkHandlers.js')
const { getBrowserWindowIcon } = require('../shared/icons.utils.js')
const { getScaledWindowSize } = require('../app/utils.ts')
const { getScaledWindowSize, showWhenWindowMarkedReady } = require('../app/utils.ts')
const { applyContextMenu } = require('../app/applyContextMenu.js')

/**
Expand Down Expand Up @@ -44,9 +44,7 @@ function createHelpWindow(parentWindow) {
applyExternalLinkHandler(window)
applyContextMenu(window)

window.on('ready-to-show', () => {
window.show()
})
showWhenWindowMarkedReady(window)

return window
}
Expand Down
3 changes: 3 additions & 0 deletions src/help/renderer/help.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import './help.styles.css'

import Vue, { defineAsyncComponent } from 'vue'
import { setupWebPage } from '../../shared/setupWebPage.js'
import { markWindowReady } from '../../shared/markWindowReady.ts'

await setupWebPage()

Expand All @@ -16,3 +17,5 @@ new Vue({
name: 'HelpAppRoot',
render: h => h(HelpApp),
}).$mount('#app')

markWindowReady()
32 changes: 16 additions & 16 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const { installVueDevtools } = require('./install-vue-devtools.js')
const { loadAppConfig, getAppConfig, setAppConfig } = require('./app/AppConfig.ts')
const { triggerDownloadUrl } = require('./app/downloads.ts')
const { applyTheme } = require('./app/theme.config.ts')
const { showWhenWindowMarkedReady, waitWindowMarkedReady } = require('./app/utils.ts')

/**
* Parse command line arguments
Expand Down Expand Up @@ -146,7 +147,7 @@ app.whenReady().then(async () => {
// There is no window (possible on macOS) - create
if (!mainWindow || mainWindow.isDestroyed()) {
mainWindow = createMainWindow()
mainWindow.once('ready-to-show', () => mainWindow.show())
showWhenWindowMarkedReady(mainWindow)
return
}

Expand Down Expand Up @@ -235,7 +236,6 @@ app.whenReady().then(async () => {

mainWindow = createWelcomeWindow()
createMainWindow = createWelcomeWindow
mainWindow.once('ready-to-show', () => mainWindow.show())

ipcMain.once('appData:receive', async (event, appData) => {
const welcomeWindow = mainWindow
Expand All @@ -256,14 +256,15 @@ app.whenReady().then(async () => {
createMainWindow = createAuthenticationWindow
}

mainWindow.once('ready-to-show', () => {
// Do not show the main window if it is the Talk Window opened in the background
const isTalkWindow = createMainWindow === createTalkWindow
if (!isTalkWindow || !ARGUMENTS.openInBackground) {
mainWindow.show()
}
welcomeWindow.close()
})
await waitWindowMarkedReady(mainWindow)

welcomeWindow.close()

// Do not show the main window if it is the Talk Window opened in the background
const isTalkWindow = createMainWindow === createTalkWindow
if (!isTalkWindow || !ARGUMENTS.openInBackground) {
mainWindow.show()
}
})

let macDockBounceId
Expand All @@ -289,19 +290,18 @@ app.whenReady().then(async () => {

ipcMain.handle('authentication:openLoginWebView', async (event, serverUrl) => openLoginWebView(mainWindow, serverUrl))

ipcMain.handle('authentication:login', async () => {
ipcMain.handle('authentication:login', () => {
mainWindow.close()
mainWindow = createTalkWindow()
createMainWindow = createTalkWindow
mainWindow.once('ready-to-show', () => mainWindow.show())
showWhenWindowMarkedReady(mainWindow)
})

ipcMain.handle('authentication:logout', async (event) => {
ipcMain.handle('authentication:logout', async () => {
if (createMainWindow === createTalkWindow) {
await mainWindow.webContents.session.clearStorageData()
const authenticationWindow = createAuthenticationWindow()
createMainWindow = createAuthenticationWindow
authenticationWindow.once('ready-to-show', () => authenticationWindow.show())

mainWindow.destroy()
mainWindow = authenticationWindow
Expand All @@ -324,7 +324,7 @@ app.whenReady().then(async () => {
isInWindowRelaunch = true
mainWindow.destroy()
mainWindow = createMainWindow()
mainWindow.once('ready-to-show', () => mainWindow.show())
showWhenWindowMarkedReady(mainWindow)
isInWindowRelaunch = false
})

Expand All @@ -340,7 +340,7 @@ app.whenReady().then(async () => {
// dock icon is clicked and there are no other windows open.
// See window-all-closed event handler.
mainWindow = createMainWindow()
mainWindow.once('ready-to-show', () => mainWindow.show())
showWhenWindowMarkedReady(mainWindow)
}
})
})
Expand Down
3 changes: 3 additions & 0 deletions src/talk/renderer/talk.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import './assets/overrides.css'
import 'regenerator-runtime' // TODO: Why isn't it added on bundling
import { initTalkHashIntegration } from './init.js'
import { setupWebPage } from '../../shared/setupWebPage.js'
import { markWindowReady } from '../../shared/markWindowReady.ts'
import { createViewer } from './Viewer/Viewer.js'
import { createDesktopApp } from './desktop.app.js'
import { registerTalkDesktopSettingsSection } from './Settings/index.ts'
Expand All @@ -35,3 +36,5 @@ window.OCA.Talk.Desktop.talkRouter.value = window.OCA.Talk.instance.$router
registerTalkDesktopSettingsSection()

await import('./notifications/notifications.store.js')

markWindowReady()
3 changes: 3 additions & 0 deletions src/upgrade/renderer/upgrade.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import '../../shared/assets/global.styles.css'
import Vue from 'vue'
import UpgradeApp from './UpgradeApp.vue'
import { setupWebPage } from '../../shared/setupWebPage.js'
import { markWindowReady } from '../../shared/markWindowReady.ts'

await setupWebPage()

new Vue(UpgradeApp).$mount('#app')

markWindowReady()
6 changes: 2 additions & 4 deletions src/upgrade/upgrade.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { BASE_TITLE } = require('../constants.js')
const { BrowserWindow } = require('electron')
const { applyExternalLinkHandler } = require('../app/externalLinkHandlers.js')
const { getBrowserWindowIcon } = require('../shared/icons.utils.js')
const { getScaledWindowSize } = require('../app/utils.ts')
const { getScaledWindowSize, showWhenWindowMarkedReady } = require('../app/utils.ts')

/**
*
Expand Down Expand Up @@ -38,9 +38,7 @@ function createUpgradeWindow() {

applyExternalLinkHandler(window)

window.on('ready-to-show', () => {
window.show()
})
showWhenWindowMarkedReady(window)

return window
}
Expand Down
3 changes: 3 additions & 0 deletions src/welcome/welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { appData } from '../app/AppData.js'
import { refetchAppDataIfDirty } from '../app/appData.service.js'
import { initGlobals } from '../shared/globals/globals.js'
import { applyAxiosInterceptors } from '../shared/setupWebPage.js'
import { markWindowReady } from '../shared/markWindowReady.ts'

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

markWindowReady()

appData.restore()

initGlobals()
Expand Down
4 changes: 3 additions & 1 deletion src/welcome/welcome.window.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const { BrowserWindow } = require('electron')
const { getBrowserWindowIcon } = require('../shared/icons.utils.js')
const { isMac } = require('../app/system.utils.ts')
const { getScaledWindowSize } = require('../app/utils.ts')
const { getScaledWindowSize, showWhenWindowMarkedReady } = require('../app/utils.ts')

/**
* @return {import('electron').BrowserWindow}
Expand Down Expand Up @@ -37,6 +37,8 @@ function createWelcomeWindow() {

window.loadURL(WELCOME_WINDOW_WEBPACK_ENTRY)

showWhenWindowMarkedReady(window)

return window
}

Expand Down

0 comments on commit 53f9f2c

Please sign in to comment.