Skip to content

Commit

Permalink
check for updates at interval
Browse files Browse the repository at this point in the history
  • Loading branch information
incognitojam committed Jul 25, 2023
1 parent a0b0c02 commit 44e9eb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
{
Expand Down
9 changes: 9 additions & 0 deletions src/components/PWAIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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);
Expand Down

0 comments on commit 44e9eb5

Please sign in to comment.