wishthis/service-worker.js

71 lines
2.6 KiB
JavaScript
Raw Normal View History

2023-09-24 11:02:02 +00:00
const service_worker = 'wishthis-v1.1.0';
const assets = [
2022-07-07 11:53:41 +00:00
'/src/assets/css/blog.css',
'/src/assets/css/default.css',
'/src/assets/css/home.css',
'/src/assets/css/install.css',
2022-07-07 11:53:41 +00:00
'/src/assets/css/post.css',
2023-01-15 12:04:42 +00:00
'/src/assets/css/wish-card.css',
'/src/assets/css/wish.css',
2022-07-07 11:53:41 +00:00
'/src/assets/css/wishlists-saved.css',
'/src/assets/css/default/dark.css',
2022-07-07 11:53:41 +00:00
'/src/assets/img/favicon.png',
'/src/assets/img/favicon.svg',
'/src/assets/img/logo-animation.svg',
'/src/assets/img/logo-readme.svg',
2022-07-07 11:53:41 +00:00
'/src/assets/img/logo-square-white-background.png',
'/src/assets/img/logo-square-white-background.svg',
'/src/assets/img/logo-square.png',
'/src/assets/img/logo-square.svg',
'/src/assets/img/logo.svg',
'/src/assets/img/no-image.svg',
'/src/assets/img/favicon/android-chrome-192x192.png',
'/src/assets/img/favicon/android-chrome-512x512.png',
'/src/assets/img/favicon/apple-touch-icon.png',
'/src/assets/img/favicon/browserconfig.xml',
'/src/assets/img/favicon/favicon-16x16.png',
'/src/assets/img/favicon/favicon-32x32.png',
'/src/assets/img/favicon/favicon.ico',
'/src/assets/img/favicon/mstile-144x144.png',
'/src/assets/img/favicon/mstile-150x150.png',
'/src/assets/img/favicon/mstile-310x150.png',
'/src/assets/img/favicon/mstile-310x310.png',
'/src/assets/img/favicon/mstile-70x70.png',
'/src/assets/img/favicon/safari-pinned-tab.svg',
2022-07-07 11:53:41 +00:00
'/src/assets/js/changelog.js',
'/src/assets/js/default.js',
'/src/assets/js/home.js',
'/src/assets/js/html2canvas.js',
'/src/assets/js/install.js',
2022-07-07 11:53:41 +00:00
'/src/assets/js/login-as.js',
'/src/assets/js/login.js',
2022-07-07 11:53:41 +00:00
'/src/assets/js/profile.js',
'/src/assets/js/register.js',
'/src/assets/js/wishlist.js',
2023-01-15 12:04:42 +00:00
'/src/assets/js/parts/wish.js',
2022-11-30 10:38:46 +00:00
'/src/assets/js/parts/wishlist-filter-priority.js',
'/src/assets/js/parts/wishlists.js',
];
2022-02-23 22:31:24 +00:00
self.addEventListener('install', installEvent => {
installEvent.waitUntil(
caches.open(service_worker).then(cache => {
cache.addAll(assets);
2022-02-23 22:31:24 +00:00
})
)
})
self.addEventListener('fetch', fetchEvent => {
fetchEvent.respondWith(
2023-09-24 11:04:00 +00:00
caches.open(service_worker).then(cache => {
return cache.match(fetchEvent.request).then(response => {
const fetchPromise = fetch(fetchEvent.request).then(networkResponse => {
cache.put(fetchEvent.request, networkResponse.clone());
return networkResponse;
});
return response || fetchPromise;
});
2022-02-23 22:31:24 +00:00
})
2023-09-24 11:04:00 +00:00
);
});