From 44e9eb5b9492b87f2fd64d6638991fb32f0e9d32 Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Tue, 25 Jul 2023 15:03:45 +0100 Subject: [PATCH] check for updates at interval --- .eslintrc.js | 3 +++ src/components/PWAIcon.jsx | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index e8fbc9ab1..552bc7c32 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -23,6 +23,9 @@ module.exports = { 'react/prop-types': 0, 'react/require-default-props': 0, 'no-await-in-loop': 'warn', + 'no-multi-spaces': ['error', { + ignoreEOLComments: true, + }], 'no-plusplus': [ 'error', { diff --git a/src/components/PWAIcon.jsx b/src/components/PWAIcon.jsx index b8f649b62..10aa8c62a 100644 --- a/src/components/PWAIcon.jsx +++ b/src/components/PWAIcon.jsx @@ -6,6 +6,8 @@ import { IconButton, Tooltip } from '@material-ui/core'; import { CheckCircle, Download } from '../icons'; +const intervalMS = 60 * 60 * 1000; // 1 hour + const PWAIcon = () => { const { offlineReady: [offlineReady, setOfflineReady], @@ -14,6 +16,13 @@ const PWAIcon = () => { } = useRegisterSW({ onRegistered: (registration) => { console.debug('[PWA] onRegistered', registration); + + if (registration) { + // Check for updates regularly + setInterval(() => { + registration.update(); + }, intervalMS); + } }, onRegisterError: (error) => { console.log('onRegisterError', error);