2022-09-16 09:36:24 -05:00
|
|
|
import Box from '@mui/material/Box'
|
|
|
|
import Button from '@mui/material/Button'
|
|
|
|
import Dialog from '@mui/material/Dialog'
|
|
|
|
import DialogActions from '@mui/material/DialogActions'
|
|
|
|
import DialogContent from '@mui/material/DialogContent'
|
|
|
|
import DialogContentText from '@mui/material/DialogContentText'
|
|
|
|
import DialogTitle from '@mui/material/DialogTitle'
|
|
|
|
import WarningIcon from '@mui/icons-material/Warning'
|
2024-03-13 03:44:43 +01:00
|
|
|
import { useRegisterSW } from 'virtual:pwa-register/react'
|
2022-09-16 09:36:24 -05:00
|
|
|
|
|
|
|
interface UpgradeDialogProps {
|
|
|
|
appNeedsUpdate: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
export const UpgradeDialog = ({ appNeedsUpdate }: UpgradeDialogProps) => {
|
2024-03-13 03:44:43 +01:00
|
|
|
const { updateServiceWorker } = useRegisterSW()
|
|
|
|
|
2022-09-16 09:36:24 -05:00
|
|
|
const handleRestartClick = () => {
|
2024-03-13 03:44:43 +01:00
|
|
|
updateServiceWorker(true)
|
2022-09-16 09:36:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Dialog
|
|
|
|
open={appNeedsUpdate}
|
|
|
|
aria-labelledby="alert-dialog-title"
|
|
|
|
aria-describedby="alert-dialog-description"
|
|
|
|
>
|
|
|
|
<DialogTitle id="alert-dialog-title">
|
|
|
|
<Box sx={{ display: 'flex', alignItems: 'center' }}>
|
|
|
|
<WarningIcon
|
|
|
|
fontSize="medium"
|
|
|
|
sx={theme => ({
|
|
|
|
color: theme.palette.warning.main,
|
|
|
|
mr: theme.spacing(1),
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
Update needed
|
|
|
|
</Box>
|
|
|
|
</DialogTitle>
|
|
|
|
<DialogContent>
|
|
|
|
<DialogContentText id="alert-dialog-description">
|
|
|
|
In order to function properly, Chitchatter needs to be updated. The
|
|
|
|
update has already been installed in the background. All you need to
|
|
|
|
do is reload the page or click "Refresh" below.
|
|
|
|
</DialogContentText>
|
|
|
|
</DialogContent>
|
|
|
|
<DialogActions>
|
|
|
|
<Button onClick={handleRestartClick} autoFocus>
|
|
|
|
Refresh
|
|
|
|
</Button>
|
|
|
|
</DialogActions>
|
|
|
|
</Dialog>
|
|
|
|
)
|
|
|
|
}
|