File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,10 @@ if ('serviceWorker' in navigator) {
1818 . then ( registration => {
1919 if ( registration ) {
2020 registration . addEventListener ( 'updatefound' , ( ) => {
21- /* console.log('updatefound'); */
2221 let serviceWorker = registration . installing ;
2322
2423 serviceWorker . addEventListener ( 'statechange' , ( ) => {
25- /* console.log(`statechange -> ${serviceWorker.state}`); */
2624 if ( serviceWorker . state === 'installed' ) {
27- /* console.log('installed'); */
2825 if ( navigator . serviceWorker . controller ) {
2926 $notification . toast ( 'show' ) ;
3027 /* in case the user ignores the notification */
@@ -39,9 +36,14 @@ if ('serviceWorker' in navigator) {
3936 $notification . toast ( 'hide' ) ;
4037 } ) ;
4138
42- /* there's a new Service Worker waiting to be activated */
4339 if ( localStorage . getItem ( keyWaiting ) ) {
44- $notification . toast ( 'show' ) ;
40+ if ( registration . waiting ) {
41+ /* there's a new Service Worker waiting to be activated */
42+ $notification . toast ( 'show' ) ;
43+ } else {
44+ /* closed all open pages after receiving notification */
45+ localStorage . removeItem ( keyWaiting ) ;
46+ }
4547 }
4648 }
4749 } ) ;
You can’t perform that action at this time.
0 commit comments