harden PWA resume and title fallback

This commit is contained in:
2026-07-23 17:29:02 -07:00
parent c5217b2710
commit 9229896ad7
5 changed files with 51 additions and 37 deletions

View File

@@ -3,7 +3,21 @@ self.addEventListener("install", () => {
});
self.addEventListener("activate", (event) => {
event.waitUntil(self.clients.claim());
event.waitUntil(
(async () => {
await self.clients.claim();
const windows = await self.clients.matchAll({ type: "window", includeUncontrolled: true });
await Promise.all(
windows.map(async (client) => {
try {
await client.navigate(client.url);
} catch {
// The client may have closed while the new worker was activating.
}
})
);
})()
);
});
self.addEventListener("fetch", (event) => {