(notification) notify when a new service worker is available.

This commit is contained in:
2020-07-05 18:41:07 +02:00
parent c8c7a7415b
commit 3ecde302c3

View File

@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import { register } from 'register-service-worker'
import { setNotificationInstance } from './utils/notification'
import { setNotificationInstance, notify } from './utils/notification'
if (process.env.NODE_ENV === 'production') {
register(`${process.env.BASE_URL}service-worker.js`, {
@@ -20,8 +20,14 @@ if (process.env.NODE_ENV === 'production') {
updatefound() {
console.log('New content is downloading.')
},
updated() {
updated(sw) {
console.log('New content is available; please refresh.')
setNotificationInstance((title, options?) =>
sw.showNotification(title, options)
)
notify('Une nouvelle version est disponible.', {
body: 'Rafraichissez la page pour mettre à jour.'
})
},
offline() {
console.log(