Skip to content

Commit

Permalink
check for new PWA app version every 8h
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Nov 19, 2023
1 parent e21db67 commit a9a879d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import ModalDialog from 'brdgm-commons/src/components/structure/ModalDialog.vue'
import { version, description } from '@/../package.json'
import { registerSW } from 'virtual:pwa-register'
import { showModalIfExist } from 'brdgm-commons/src/util/modal/showModal'
import onRegisteredSWCheckForUpdate from 'brdgm-commons/src/util/serviceWorker/onRegisteredSWCheckForUpdate'
export default defineComponent({
name: 'App',
Expand All @@ -77,8 +78,13 @@ export default defineComponent({
})
const store = useStore()
// PWA refresh
// handle PWA updates with prompt if a new version is detected, check every 8h for a new version
const checkForNewVersionsIntervalSeconds = 8 * 60 * 60
const updateServiceWorker = registerSW({
// check for new app version, see https://vite-pwa-org.netlify.app/guide/periodic-sw-updates.html
onRegisteredSW(swScriptUrl : string, registration? : ServiceWorkerRegistration) {
onRegisteredSWCheckForUpdate(swScriptUrl, registration, checkForNewVersionsIntervalSeconds)
},
onNeedRefresh() {
showModalIfExist('serviceWorkerUpdatedRefresh')
}
Expand Down

0 comments on commit a9a879d

Please sign in to comment.