@@ -76,18 +76,16 @@ function getOriginFromUrl(url: string): string {
7676
7777self . addEventListener ( 'install' , ( event : ExtendableEvent ) => {
7878 // Perform install steps.
79- event . waitUntil (
80- async ( ) : Promise < void > => {
81- const cache = await caches . open ( CACHE_NAME ) ;
82- // Add all URLs of resources we want to cache.
83- try {
84- await cache . addAll ( urlsToCache ) ;
85- } catch {
86- // Suppress error as some of the files may not be available for the
87- // current page.
88- }
79+ event . waitUntil ( async ( ) : Promise < void > => {
80+ const cache = await caches . open ( CACHE_NAME ) ;
81+ // Add all URLs of resources we want to cache.
82+ try {
83+ await cache . addAll ( urlsToCache ) ;
84+ } catch {
85+ // Suppress error as some of the files may not be available for the
86+ // current page.
8987 }
90- ) ;
88+ } ) ;
9189} ) ;
9290
9391// As this is a test app, let's only return cached data when offline.
@@ -160,18 +158,16 @@ self.addEventListener('fetch', (event: FetchEvent) => {
160158self . addEventListener ( 'activate' , ( event : ExtendableEvent ) => {
161159 // Update this list with all caches that need to remain cached.
162160 const cacheWhitelist = [ 'cache-v1' ] ;
163- event . waitUntil (
164- async ( ) : Promise < void > => {
165- const cacheNames = await caches . keys ( ) ;
166- await Promise . all (
167- cacheNames . map ( cacheName => {
168- // Check if cache is not whitelisted above.
169- if ( cacheWhitelist . indexOf ( cacheName ) === - 1 ) {
170- // If not whitelisted, delete it.
171- return caches . delete ( cacheName ) ;
172- }
173- } )
174- ) ;
175- }
176- ) ;
161+ event . waitUntil ( async ( ) : Promise < void > => {
162+ const cacheNames = await caches . keys ( ) ;
163+ await Promise . all (
164+ cacheNames . map ( cacheName => {
165+ // Check if cache is not whitelisted above.
166+ if ( cacheWhitelist . indexOf ( cacheName ) === - 1 ) {
167+ // If not whitelisted, delete it.
168+ return caches . delete ( cacheName ) ;
169+ }
170+ } )
171+ ) ;
172+ } ) ;
177173} ) ;
0 commit comments