Skip to content

Commit

Permalink
Remove page reload in pwa.js. (#24923)
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR authored Dec 5, 2017
1 parent 3a0f8d7 commit af34799
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions assets/js/src/pwa.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,11 @@
window.addEventListener('load', function () {
navigator.serviceWorker.register('/sw.js').then(function (registration) { // eslint-disable-line compat/compat
console.log('ServiceWorker registration successful with scope: ', registration.scope)
registration.onupdatefound = function () {
var installingWorker = registration.installing
installingWorker.onstatechange = function () {
switch (installingWorker.state) {
case 'installed':
if (navigator.serviceWorker.controller) { // eslint-disable-line compat/compat
console.log('new update available')
location.reload(true)
}
break

default:
}
}
}
}).catch(function (err) {
console.log('ServiceWorker registration failed: ', err)
})
})
} else {
console.log('Service workers are not supported.')
}
}())

0 comments on commit af34799

Please sign in to comment.