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