From a5cf24ff32da2d6428eeab3e6b4fa41de7d4b82c Mon Sep 17 00:00:00 2001 From: Matjaž Črnko Date: Mon, 6 Nov 2023 00:53:00 +0100 Subject: PWA: Move ReloadPrompt to an initialized location, so that Attributes work --- modern/src/App.jsx | 2 ++ modern/src/ReloadPrompt.tsx | 7 +------ modern/src/index.jsx | 2 -- 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 = () => { <> +
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( - -- cgit v1.2.3