Skip to content

Commit

Permalink
Revert "Make it more clear which file is cached and wether or not is …
Browse files Browse the repository at this point in the history
…has succeeded"

This reverts commit d63fdcf.
  • Loading branch information
rcmenno committed Sep 19, 2024
1 parent af9b3dd commit c478bf7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 41 deletions.
23 changes: 3 additions & 20 deletions PWA/public/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,19 @@ self.addEventListener("install", function (event) {
console.log("ℹ️ Installing Service Worker ...", event);
console.log(new CacheFilePathService().pathsOfFilesToCache());
event.waitUntil(caches.open(CACHE_STATIC_NAME)
.then(async (cache) => {
.then(function (cache) {
console.log("ℹ️ Precaching App Shell..");
const urlsToCache = [
cache.addAll([
"/",
"/favicon.ico",
"/manifest.json",
"/apple-touch-icon.png",
"/apple-touch-icon-precomposed.png"
]
.concat(new CacheFilePathService().pathsOfFilesToCache());
for (const url of urlsToCache) {
try {
const response = await fetch(url);
if (!response.ok) {
console.error(`Failed to fetch ${url}: ${response.statusText}`);
}
else {
await cache.put(url, response);
console.log(`Cached: ${url}`);
}
}
catch (error) {
console.error(`Error fetching ${url}:`, error);
}
}
.concat(new CacheFilePathService().pathsOfFilesToCache()));
})
.then(() => {
console.log("ℹ️ Serviceworker installed ✅");
}).catch((error) => {
console.error("Promise rejected with:", error);
}));
});
self.addEventListener("activate", function (event) {
Expand Down
24 changes: 3 additions & 21 deletions PWA/src/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,20 @@ self.addEventListener("install", function (event: any) {
console.log(new CacheFilePathService().pathsOfFilesToCache())
event.waitUntil(
caches.open(CACHE_STATIC_NAME)
.then(async (cache) => {
.then(function (cache) {
console.log("ℹ️ Precaching App Shell..");
const urlsToCache = [
cache.addAll([
"/",
"/favicon.ico",
"/manifest.json",
"/apple-touch-icon.png",
"/apple-touch-icon-precomposed.png"
]
.concat(new CacheFilePathService().pathsOfFilesToCache())

for (const url of urlsToCache) {
try {
const response = await fetch(url);
if (!response.ok) {
console.error(`Failed to fetch ${url}: ${response.statusText}`);
} else {
await cache.put(url, response);
console.log(`Cached: ${url}`);
}
} catch (error) {
console.error(`Error fetching ${url}:`, error);
}
}
);
})
.then(() => {
console.log("ℹ️ Serviceworker installed ✅")
}).catch((error) => {
console.error("Promise rejected with:", error);
})
);
});
Expand All @@ -59,9 +44,6 @@ self.addEventListener("activate", function (event: any) {
})
);
})
.catch((error) => {
console.error("Promise rejected with:", error);
})
);
return (self as any).clients.claim();
});
Expand Down

0 comments on commit c478bf7

Please sign in to comment.