File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -235,7 +235,7 @@ self.addEventListener( 'install', async function () {
235235
236236 const cache = await caches . open ( cacheName ) ;
237237
238- assets . forEach ( async function ( asset ) {
238+ await Promise . all ( assets . map ( async function ( asset ) {
239239
240240 try {
241241
@@ -247,7 +247,27 @@ self.addEventListener( 'install', async function () {
247247
248248 }
249249
250- } ) ;
250+ } ) ) ;
251+
252+ self . skipWaiting ( ) ;
253+
254+ } ) ;
255+
256+ self . addEventListener ( 'activate' , async function ( event ) {
257+
258+ event . waitUntil (
259+ caches . keys ( ) . then ( function ( names ) {
260+
261+ return Promise . all (
262+ names . filter ( name => name !== cacheName ) . map ( name => caches . delete ( name ) )
263+ ) ;
264+
265+ } ) . then ( function ( ) {
266+
267+ self . clients . claim ( ) ;
268+
269+ } )
270+ ) ;
251271
252272} ) ;
253273
You can’t perform that action at this time.
0 commit comments