mirror of
https://github.com/kremalicious/blog.git
synced 2025-02-14 21:10:25 +01:00
Display a message when a service worker updates
This commit is contained in:
parent
a575752284
commit
64e6a32ce8
@ -4,3 +4,15 @@ import './src/styles/global.scss'
|
|||||||
if (typeof window.IntersectionObserver === 'undefined') {
|
if (typeof window.IntersectionObserver === 'undefined') {
|
||||||
import('intersection-observer')
|
import('intersection-observer')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Display a message when a service worker updates
|
||||||
|
// https://www.gatsbyjs.org/docs/add-offline-support-with-a-service-worker/#displaying-a-message-when-a-service-worker-updates
|
||||||
|
export const onServiceWorkerUpdateReady = () => {
|
||||||
|
const answer = window.confirm(
|
||||||
|
`This application has been updated. ` +
|
||||||
|
`Reload to display the latest version?`
|
||||||
|
)
|
||||||
|
if (answer === true) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user