aboutsummaryrefslogtreecommitdiff
path: root/modern/src/UpdateController.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/UpdateController.jsx')
-rw-r--r--modern/src/UpdateController.jsx22
1 files changed, 11 insertions, 11 deletions
diff --git a/modern/src/UpdateController.jsx b/modern/src/UpdateController.jsx
index 0b2b7985..80ca6dc2 100644
--- a/modern/src/UpdateController.jsx
+++ b/modern/src/UpdateController.jsx
@@ -1,12 +1,12 @@
import { Snackbar, IconButton } from '@mui/material';
import RefreshIcon from '@mui/icons-material/Refresh';
-import React from 'react'
+import React from 'react';
import { useSelector } from 'react-redux';
+import { useRegisterSW } from 'virtual:pwa-register/react';
import { useTranslation } from './common/components/LocalizationProvider';
-import { useRegisterSW } from 'virtual:pwa-register/react'
// Based on https://vite-pwa-org.netlify.app/frameworks/react.html
-function UpdateController() {
+const UpdateController = () => {
const t = useTranslation();
const swUpdateInterval = useSelector((state) => state.session.server.attributes.serviceWorkerUpdateInterval || 3600000);
@@ -21,30 +21,30 @@ function UpdateController() {
if (!(!swRegistration.installing && navigator)) {
return;
}
-
+
if (('connection' in navigator) && !navigator.onLine) {
return;
}
-
+
const newSW = await fetch(swUrl, {
cache: 'no-store',
headers: {
- 'cache': 'no-store',
+ cache: 'no-store',
'cache-control': 'no-cache',
},
});
-
+
if (newSW?.status === 200) {
await swRegistration.update();
}
}, swUpdateInterval);
}
- }
+ },
});
return (
- <Snackbar
- open={needRefresh}
+ <Snackbar
+ open={needRefresh}
message={t('settingsUpdateAvailable')}
action={(
<IconButton color="inherit" onClick={() => updateServiceWorker(true)}>
@@ -53,6 +53,6 @@ function UpdateController() {
)}
/>
);
-}
+};
export default UpdateController;