-
-
Notifications
You must be signed in to change notification settings - Fork 785
/
Copy pathrenderer.tsx
59 lines (54 loc) · 1.59 KB
/
renderer.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Button from '@mui/material/Button'
import Grid from '@mui/material/Grid'
import Typography from '@mui/material/Typography'
import AppWrapper from 'browser/components/AppWrapper'
import renderWhenReady from 'browser/helpers/renderWhenReady'
import React from 'react'
const completeStatus = 'Update Downloaded'
let lastStatus = ''
// @ts-expect-error just whatever
window.setStatus = (status: string) => {
lastStatus = status
}
const UpdateNotifier = () => {
const [status, setStatus] = React.useState(lastStatus)
React.useEffect(() => {
// @ts-expect-error just whatever
window.setStatus = setStatus
setStatus(lastStatus)
}, [])
// @ts-expect-error this exists
const doRestart = () => window.doRestart()
const close = () => window.close()
return (
<AppWrapper>
<Grid className="centered pt-4" container spacing={1}>
<Grid item xs={12}>
<Typography variant="subtitle1">{status}</Typography>
</Grid>
{status === completeStatus && (
<>
<Grid item xs={6}>
<Button onClick={close} variant="outlined">
OK
</Button>
</Grid>
<Grid item xs={6}>
<Button onClick={doRestart} variant="contained">
Restart
</Button>
</Grid>
</>
)}
{status.startsWith('Error') && (
<Grid item xs={12}>
<Button onClick={close} variant="outlined">
OK
</Button>
</Grid>
)}
</Grid>
</AppWrapper>
)
}
renderWhenReady(UpdateNotifier)