Skip to content

Commit 0acf2b3

Browse files
committed
auto updater system yay
1 parent f6ff296 commit 0acf2b3

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

packages/selenium-ide/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "selenium-ide",
3-
"version": "4.0.1-alpha.86",
3+
"version": "4.0.1-alpha.87",
44
"private": false,
55
"description": "Selenium IDE electron app",
66
"author": "Todd <tarsitodd@gmail.com>",

packages/selenium-ide/src/browser/windows/UpdateNotifier/controller.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { WindowConfig } from 'browser/types'
22
import Electron from 'electron'
33

4-
const WIDTH = 400
5-
const HEIGHT = 150
4+
const WIDTH = 300
5+
const HEIGHT = 120
66

77
export const window: WindowConfig['window'] = () => {
88
const display = Electron.screen.getPrimaryDisplay()
@@ -15,12 +15,11 @@ export const window: WindowConfig['window'] = () => {
1515
minimizable: false,
1616
fullscreenable: false,
1717
autoHideMenuBar: true,
18+
frame: false,
1819
maximizable: false,
19-
show: false,
2020
skipTaskbar: true,
2121
useContentSize: false,
22-
modal: true,
23-
title: 'Update checker',
22+
title: 'Checking for updates',
2423
webPreferences: {
2524
contextIsolation: true,
2625
nodeIntegration: false,

packages/selenium-ide/src/browser/windows/UpdateNotifier/renderer.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ import AppWrapper from 'browser/components/AppWrapper'
55
import renderWhenReady from 'browser/helpers/renderWhenReady'
66
import React from 'react'
77

8-
const completeStatus = 'Update has been installed and will be applied on restart.'
8+
const completeStatus =
9+
'Update has been installed and will be applied on restart.'
10+
11+
let lastStatus = ''
12+
// @ts-expect-error just whatever
13+
window.setStatus = (status: string) => {
14+
lastStatus = status
15+
}
916

1017
const UpdateNotifier = () => {
11-
const [status, setStatus] = React.useState('Checking for updates...')
18+
const [status, setStatus] = React.useState(lastStatus)
1219
React.useEffect(() => {
1320
// @ts-expect-error just whatever
1421
window.setStatus = setStatus
22+
setStatus(lastStatus)
1523
}, [])
1624
// @ts-expect-error this exists
1725
const completeUpdateNotifier = () => window.completeUpdateNotifier()
@@ -23,9 +31,8 @@ const UpdateNotifier = () => {
2331
<Grid item xs={12}>
2432
<Typography variant="subtitle1">{status}</Typography>
2533
</Grid>
26-
</Grid>
2734
{status === completeStatus && (
28-
<Grid className="centered" container spacing={1}>
35+
<>
2936
<Grid item xs={6}>
3037
<Button onClick={closeUpdateNotifier} variant="outlined">
3138
OK
@@ -36,17 +43,16 @@ const UpdateNotifier = () => {
3643
Restart Now
3744
</Button>
3845
</Grid>
39-
</Grid>
46+
</>
4047
)}
4148
{status.startsWith('Error') && (
42-
<Grid className="centered" container spacing={1}>
43-
<Grid item xs={6}>
49+
<Grid item xs={12}>
4450
<Button onClick={closeUpdateNotifier} variant="outlined">
4551
OK
4652
</Button>
4753
</Grid>
48-
</Grid>
4954
)}
55+
</Grid>
5056
</AppWrapper>
5157
)
5258
}

packages/selenium-ide/src/main/session/controllers/System/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export default class SystemController extends BaseController {
4949
if (this.isDown) {
5050
// If automated, assume we already have a chromedriver process running
5151
if (!isAutomated) {
52+
this.checkForUpdates()
5253
const startupError = await this.session.driver.startProcess(
5354
this.session.store.get('browserInfo')
5455
)
@@ -76,7 +77,6 @@ export default class SystemController extends BaseController {
7677
await this.session.api.system.onLog.addListener(this.writeToLog)
7778
this.isDown = false
7879
firstTime = false
79-
this.checkForUpdates()
8080
}
8181
}
8282

@@ -118,7 +118,13 @@ export default class SystemController extends BaseController {
118118
ipcMain.once('do-restart', () => {
119119
autoUpdater.quitAndInstall()
120120
})
121-
autoUpdater.checkForUpdatesAndNotify()
121+
const promise = await autoUpdater.checkForUpdatesAndNotify()
122+
if (promise === null) {
123+
window.webContents.executeJavaScript(
124+
'window.setStatus("No Update Available")'
125+
)
126+
setTimeout(() => window.close(), 5000)
127+
}
122128
}
123129

124130
async shutdown() {

0 commit comments

Comments
 (0)