Skip to content

Commit

Permalink
chore(app-shell-odd): update electron builder config (#14600)
Browse files Browse the repository at this point in the history
Update the ODD to use electron 27.

slightly changes the app's initialization flow in ODD; we now `show()` after the first dispatch from the app side, since `ready-to-show` isn't firing.
  • Loading branch information
koji authored Mar 19, 2024
1 parent 1804321 commit d370ba8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app-shell-odd/electron-builder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = {
appId: 'com.opentrons.odd',
electronVersion: '23.3.13',
electronVersion: '27.0.0',
npmRebuild: false,
files: [
'**/*',
Expand Down
10 changes: 9 additions & 1 deletion app-shell-odd/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { app, ipcMain } from 'electron'
import dns from 'dns'
import fse from 'fs-extra'
import path from 'path'
import { createUi } from './ui'
import { createUi, waitForRobotServerAndShowMainWindow } from './ui'
import { createLogger } from './log'
import { registerDiscovery } from './discovery'
import {
Expand Down Expand Up @@ -122,10 +122,18 @@ function startUp(): void {
log.silly('Global references', { mainWindow, rendererLogger })

ipcMain.once('dispatch', () => {
log.info('First dispatch, showing')
systemd.sendStatus('started')
systemd.ready()
const stopWatching = watchForMassStorage(dispatch)
ipcMain.once('quit', stopWatching)
// TODO: This is where we render the main window for the first time. See ui.ts
// in the createUI function for more.
if (!!!mainWindow) {
log.error('mainWindow went away before show')
} else {
waitForRobotServerAndShowMainWindow(dispatch, mainWindow)
}
})
}

Expand Down
50 changes: 26 additions & 24 deletions app-shell-odd/src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,12 @@ const WINDOW_OPTS = {
export function createUi(dispatch: Dispatch): BrowserWindow {
log.debug('Creating main window', { options: WINDOW_OPTS })

const mainWindow = new BrowserWindow(WINDOW_OPTS).once(
'ready-to-show',
() => {
log.debug('Main window ready to show')
mainWindow.show()
process.env.NODE_ENV !== 'development' &&
waitForRobotServerAndShowMainWIndow(dispatch)
}
)
const mainWindow = new BrowserWindow(WINDOW_OPTS)
// TODO: In the app, we immediately do .once('ready-to-show', () => { mainWindow.show() }). We don't do that
// here because in electron 27.0.0 for some reason ready-to-show isn't firing, so instead we use "the app sent
// something via IPC" as our signifier that the window can bw shown. This happens in main.ts.
// This is a worrying thing to have to do, and it would be good to stop doing it. We'll have to change this
// further when we upgrade past 27.

log.info(`Loading ${url}`)
// eslint-disable-next-line @typescript-eslint/no-floating-promises
Expand All @@ -66,19 +63,24 @@ export function createUi(dispatch: Dispatch): BrowserWindow {
return mainWindow
}

export function waitForRobotServerAndShowMainWIndow(dispatch: Dispatch): void {
setTimeout(function () {
systemd
.getisRobotServerReady()
.then((isReady: boolean) => {
dispatch(sendReadyStatus(isReady))
if (!isReady) {
waitForRobotServerAndShowMainWIndow(dispatch)
}
})
.catch(e => {
log.debug('Could not get status of robot server service', { e })
waitForRobotServerAndShowMainWIndow(dispatch)
})
}, 1500)
export function waitForRobotServerAndShowMainWindow(
dispatch: Dispatch,
mainWindow: BrowserWindow
): void {
mainWindow.show()
process.env.NODE_ENV !== 'development' &&
setTimeout(function () {
systemd
.getisRobotServerReady()
.then((isReady: boolean) => {
dispatch(sendReadyStatus(isReady))
if (!isReady) {
waitForRobotServerAndShowMainWindow(dispatch, mainWindow)
}
})
.catch(e => {
log.debug('Could not get status of robot server service', { e })
waitForRobotServerAndShowMainWindow(dispatch, mainWindow)
})
}, 1500)
}

0 comments on commit d370ba8

Please sign in to comment.