aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/public/pwa-worker.js
diff options
context:
space:
mode:
authorcopilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>2025-11-06 22:52:02 +0000
committerAriel Costas Guerrero <ariel@costas.dev>2025-11-07 10:47:20 +0100
commitee77f38cdb324cbcf12518490df77fc9e6b89282 (patch)
tree407f64a434291e1e375e6a1ccb55f59fa886a1ef /src/frontend/public/pwa-worker.js
parente51cdd89afc08274ca622e18b8127feca29e90a3 (diff)
Improve gallery scroll indicators and format code
Co-authored-by: arielcostas <94913521+arielcostas@users.noreply.github.com>
Diffstat (limited to 'src/frontend/public/pwa-worker.js')
-rw-r--r--src/frontend/public/pwa-worker.js28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/frontend/public/pwa-worker.js b/src/frontend/public/pwa-worker.js
index bfe4b7e..13c1978 100644
--- a/src/frontend/public/pwa-worker.js
+++ b/src/frontend/public/pwa-worker.js
@@ -1,12 +1,9 @@
const CACHE_VERSION = "20251107a";
const STATIC_CACHE_NAME = `static-cache-${CACHE_VERSION}`;
-const STATIC_CACHE_ASSETS = [
- "/favicon.ico",
- "/logo-256.png",
- "/logo-512.jpg"
-];
+const STATIC_CACHE_ASSETS = ["/favicon.ico", "/logo-256.png", "/logo-512.jpg"];
-const EXPR_CACHE_AFTER_FIRST_VIEW = /(\/assets\/.*)|(\/api\/(vigo|santiago)\/GetStopTimetable.*)/;
+const EXPR_CACHE_AFTER_FIRST_VIEW =
+ /(\/assets\/.*)|(\/api\/(vigo|santiago)\/GetStopTimetable.*)/;
const ESTIMATES_MIN_AGE = 15 * 1000;
const ESTIMATES_MAX_AGE = 30 * 1000;
@@ -14,9 +11,10 @@ const ESTIMATES_MAX_AGE = 30 * 1000;
self.addEventListener("install", (event) => {
console.log("SW: Install event in progress. Cache version: ", CACHE_VERSION);
event.waitUntil(
- caches.open(STATIC_CACHE_NAME).then((cache) =>
- cache.addAll(STATIC_CACHE_ASSETS)
- ).then(() => self.skipWaiting())
+ caches
+ .open(STATIC_CACHE_NAME)
+ .then((cache) => cache.addAll(STATIC_CACHE_ASSETS))
+ .then(() => self.skipWaiting()),
);
});
@@ -29,11 +27,11 @@ self.addEventListener("activate", (event) => {
if (name !== STATIC_CACHE_NAME) {
return caches.delete(name);
}
- })
+ }),
);
await self.clients.claim();
- }
+ };
event.waitUntil(doCleanup());
});
@@ -43,7 +41,7 @@ self.addEventListener("fetch", async (event) => {
const url = new URL(request.url);
// Ignore requests with unsupported schemes
- if (!url.protocol.startsWith('http')) {
+ if (!url.protocol.startsWith("http")) {
return;
}
@@ -53,7 +51,9 @@ self.addEventListener("fetch", async (event) => {
}
// Static => cache first, if not, network; if not, fallback
- const isAssetCacheable = STATIC_CACHE_ASSETS.includes(url.pathname) || EXPR_CACHE_AFTER_FIRST_VIEW.test(url.pathname);
+ const isAssetCacheable =
+ STATIC_CACHE_ASSETS.includes(url.pathname) ||
+ EXPR_CACHE_AFTER_FIRST_VIEW.test(url.pathname);
if (request.method === "GET" && isAssetCacheable) {
const response = handleStaticRequest(request);
if (response !== null) {
@@ -66,7 +66,7 @@ self.addEventListener("fetch", async (event) => {
async function handleStaticRequest(request) {
const cache = await caches.open(STATIC_CACHE_NAME);
const cachedResponse = await cache.match(request);
- if (cachedResponse){
+ if (cachedResponse) {
console.log("SW handleStaticRequest: HIT for ", request.url);
return cachedResponse;
}