Fixed syntax issue.

This commit is contained in:
retoor 2025-07-04 06:03:53 +02:00
parent 8ce607d787
commit 634aa535de

View File

@ -1,7 +1,7 @@
function isClientOpen(url) {
return self.clients.matchAll().then((clients) => {
return clients.some((client) => {
return client.url === url && "focus" in client;
return clients.matchAll().then((matchedClients) => {
return matchedClients.some((matchedClient) => {
return matchedClient.url === url && "focus" in matchedClient;
});
});
}
@ -19,7 +19,8 @@ self.addEventListener("activate", (event) => {
event.waitUntil(self.registration?.navigationPreload.enable());
});
self.addEventListener("push", (event) => {
self.addEventListener("push", async (event) => {
if (!self.Notification || self.Notification.permission !== "granted") {
console.log("Notification permission not granted");
return;
@ -28,7 +29,7 @@ self.addEventListener("push", (event) => {
const data = event.data?.json() ?? {};
console.log("Received a push message", event, data);
if(isClientOpen(data.url || data.link || `/web.html`)){
if(await isClientOpen(data.url || data.link || `/web.html`)){
console.log("Client already open, not showing notification.");
return;
}