aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-03-06 23:28:02 -0800
committerAdam Soltys <[email protected]>2026-03-06 23:28:02 -0800
commit6385fc236ead6d156ef2ff2defd7f43586b99177 (patch)
treeff77add73582470dcd89c21bc9f2b686227375a9
parentb3020d0d82a58c3179c9a49dbe196e40a1cbee14 (diff)
downloadcoinos-ui-6385fc236ead6d156ef2ff2defd7f43586b99177.tar.gz
coinos-ui-6385fc236ead6d156ef2ff2defd7f43586b99177.zip
fix notification click to reuse existing tab
Co-Authored-By: Claude Opus 4.6 <[email protected]>
-rw-r--r--src/service-worker.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/service-worker.js b/src/service-worker.js
index ca0d472b..89f4cf47 100644
--- a/src/service-worker.js
+++ b/src/service-worker.js
@@ -127,17 +127,19 @@ self.addEventListener("push", (event) => {
self.addEventListener("notificationclick", (event) => {
event.notification.close();
- const url = event.notification.data.url || "/";
+ const path = event.notification.data.url || "/";
+ const target = new URL(path, self.location.origin).href;
event.waitUntil(
clients.matchAll({ type: "window", includeUncontrolled: true }).then((clientList) => {
for (const client of clientList) {
- if (client.url === url && "focus" in client) {
+ if (new URL(client.url).origin === self.location.origin && "focus" in client) {
+ client.navigate(target);
return client.focus();
}
}
if (clients.openWindow) {
- return clients.openWindow(url);
+ return clients.openWindow(target);
}
}),
);