import { PureComponent } from 'react'; import Box from '@mui/material/Box'; import Button from '@mui/material/Button'; import DialogTitle from '@mui/material/DialogTitle'; import DialogContent from '@mui/material/DialogContent'; import DialogContentText from '@mui/material/DialogContentText'; import DialogActions from '@mui/material/DialogActions'; import CircularProgress from '@mui/material/CircularProgress'; import SystemUpdateAltIcon from '@mui/icons-material/SystemUpdateAlt'; import AppDialog from './AppDialog'; import pwaAutomat from '../automats/pwaAutomat'; /** * PWA Update prompt dialog. * Appears when a new service worker update has been downloaded in the background. * Allows the user to reload the page to apply the update immediately, * or postpone it ("Später") without losing ongoing form input. */ export default class PwaUpdateDialog extends PureComponent { constructor(props) { super(props); this.state = { dialogOpen: pwaAutomat.state.dialogOpen, updating: pwaAutomat.state.updating, }; this.handleUpdate = this.handleUpdate.bind(this); this.handleClose = this.handleClose.bind(this); } componentDidMount() { this.unsub = pwaAutomat.subscribe(this, ['dialogOpen', 'updating']); } componentWillUnmount() { this.unsub?.(); } handleClose() { if (this.state.updating) return; pwaAutomat.actions.closeDialog(); } handleUpdate() { pwaAutomat.actions.applyUpdate(); } render() { const { dialogOpen, updating } = this.state; return ( Aktualisierung verfügbar Eine neue Version von Dashfront ist bereit. Möchten Sie die Anwendung jetzt neu laden, um die Änderungen zu übernehmen? Stellen Sie sicher, dass wichtige Eingaben gespeichert sind. ); } }