aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatjaž Črnko <m.crnko@txt.si>2023-11-06 00:53:00 +0100
committerMatjaž Črnko <m.crnko@txt.si>2023-11-06 00:53:00 +0100
commita5cf24ff32da2d6428eeab3e6b4fa41de7d4b82c (patch)
tree1d4424c65345e3e24cb24b98de219ca892e56cba
parent31649a7d37d1b3ee52c690dcf0cedf874389ef17 (diff)
downloadtrackermap-web-a5cf24ff32da2d6428eeab3e6b4fa41de7d4b82c.tar.gz
trackermap-web-a5cf24ff32da2d6428eeab3e6b4fa41de7d4b82c.tar.bz2
trackermap-web-a5cf24ff32da2d6428eeab3e6b4fa41de7d4b82c.zip
PWA: Move ReloadPrompt to an initialized location, so that Attributes work
-rw-r--r--modern/src/App.jsx2
-rw-r--r--modern/src/ReloadPrompt.tsx7
-rw-r--r--modern/src/index.jsx2
3 files changed, 3 insertions, 8 deletions
diff --git a/modern/src/App.jsx b/modern/src/App.jsx
index 89785cfa..3e491d49 100644
--- a/modern/src/App.jsx
+++ b/modern/src/App.jsx
@@ -8,6 +8,7 @@ import SocketController from './SocketController';
import CachingController from './CachingController';
import { useEffectAsync } from './reactHelper';
import { sessionActions } from './store';
+import ReloadPrompt from './ReloadPrompt';
const useStyles = makeStyles(() => ({
page: {
@@ -48,6 +49,7 @@ const App = () => {
<>
<SocketController />
<CachingController />
+ <ReloadPrompt />
<div className={classes.page}>
<Outlet />
</div>
diff --git a/modern/src/ReloadPrompt.tsx b/modern/src/ReloadPrompt.tsx
index 1f93f913..3aa7ca42 100644
--- a/modern/src/ReloadPrompt.tsx
+++ b/modern/src/ReloadPrompt.tsx
@@ -1,17 +1,14 @@
import { Snackbar, Button } from '@mui/material';
import React from 'react'
import { useTranslation } from './common/components/LocalizationProvider';
-
import { useAttributePreference } from './common/util/preferences';
-
import { useRegisterSW } from 'virtual:pwa-register/react'
// Based on https://vite-pwa-org.netlify.app/frameworks/react.html
function ReloadPrompt() {
const t = useTranslation();
- // const serviceWorkerUpdateInterval = useAttributePreference('serviceWorkerUpdateInterval', 3600000);
- const serviceWorkerUpdateInterval = 60000;
+ const serviceWorkerUpdateInterval = useAttributePreference('serviceWorkerUpdateInterval', 3600000);
const {
offlineReady: [offlineReady, setOfflineReady],
@@ -19,8 +16,6 @@ function ReloadPrompt() {
updateServiceWorker,
} = useRegisterSW({
onRegisteredSW(swUrl, r) {
- console.log('serviceWorkerUpdateCheck', serviceWorkerUpdateInterval);
-
serviceWorkerUpdateInterval > 0 && r && setInterval(async () => {
if (!(!r.installing && navigator)) {
return;
diff --git a/modern/src/index.jsx b/modern/src/index.jsx
index 0c342b23..3eb96d2f 100644
--- a/modern/src/index.jsx
+++ b/modern/src/index.jsx
@@ -16,7 +16,6 @@ import NativeInterface from './common/components/NativeInterface';
import ServerProvider from './ServerProvider';
import ErrorBoundary from './ErrorBoundary';
import AppThemeProvider from './AppThemeProvider';
-import ReloadPrompt from './ReloadPrompt';
preloadImages();
@@ -32,7 +31,6 @@ root.render(
<BrowserRouter>
<Navigation />
</BrowserRouter>
- <ReloadPrompt />
<ErrorHandler />
<NativeInterface />
</ServerProvider>