Try and improve notification opening behavior

This commit is contained in:
Nicolas Mowen 2025-11-12 16:29:12 -07:00
parent 426699d3d0
commit 2d06055bbe

View File

@ -44,11 +44,16 @@ self.addEventListener("notificationclick", (event) => {
switch (event.action ?? "default") { switch (event.action ?? "default") {
case "markReviewed": case "markReviewed":
if (event.notification.data) { if (event.notification.data) {
fetch("/api/reviews/viewed", { event.waitUntil(
method: "POST", fetch("/api/reviews/viewed", {
headers: { "Content-Type": "application/json", "X-CSRF-TOKEN": 1 }, method: "POST",
body: JSON.stringify({ ids: [event.notification.data.id] }), headers: {
}); "Content-Type": "application/json",
"X-CSRF-TOKEN": 1,
},
body: JSON.stringify({ ids: [event.notification.data.id] }),
})
);
} }
break; break;
default: default:
@ -58,7 +63,7 @@ self.addEventListener("notificationclick", (event) => {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
if (clients.openWindow) { if (clients.openWindow) {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
return clients.openWindow(url); event.waitUntil(clients.openWindow(url));
} }
} }
} }