A music player that connects to your cloud/distributed storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: safer service worker behaviour

+12 -5
+12 -5
src/service-worker-offline.js
··· 22 22 // INSTALL 23 23 //////////////////////////////////////////// 24 24 25 - self.addEventListener("install", () => { 25 + self.addEventListener("install", (_event) => { 26 26 // Activate immediately without waiting for existing clients to close. 27 - thyself.skipWaiting(); 27 + /** @type {ExtendableEvent} */ (_event).waitUntil(thyself.skipWaiting()); 28 28 }); 29 29 30 30 //////////////////////////////////////////// ··· 32 32 //////////////////////////////////////////// 33 33 34 34 self.addEventListener("activate", (event) => { 35 - // Take control of all open clients right away. 36 - /** @type {ExtendableEvent} */ (event).waitUntil(thyself.clients.claim()); 35 + // Take control of all open clients right away, then reload them so every 36 + // page starts fresh under the new service worker with no mid-session split. 37 + /** @type {ExtendableEvent} */ (event).waitUntil( 38 + thyself.clients.claim().then(() => 39 + thyself.clients.matchAll({ type: "window" }).then((clients) => { 40 + for (const client of clients) client.navigate(client.url); 41 + }) 42 + ) 43 + ); 37 44 }); 38 45 39 46 //////////////////////////////////////////// ··· 187 194 188 195 // Cache full successful responses, including opaque cross-origin ones. 189 196 if (response.status === 200 || response.type === "opaque") { 190 - store(request, response.clone()); 197 + store(request, response.clone()).catch(() => {}); 191 198 } 192 199 193 200 return response;