Fixed syntax issue.
This commit is contained in:
parent
8ce607d787
commit
634aa535de
@ -1,7 +1,7 @@
|
|||||||
function isClientOpen(url) {
|
function isClientOpen(url) {
|
||||||
return self.clients.matchAll().then((clients) => {
|
return clients.matchAll().then((matchedClients) => {
|
||||||
return clients.some((client) => {
|
return matchedClients.some((matchedClient) => {
|
||||||
return client.url === url && "focus" in client;
|
return matchedClient.url === url && "focus" in matchedClient;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -19,7 +19,8 @@ self.addEventListener("activate", (event) => {
|
|||||||
event.waitUntil(self.registration?.navigationPreload.enable());
|
event.waitUntil(self.registration?.navigationPreload.enable());
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener("push", (event) => {
|
|
||||||
|
self.addEventListener("push", async (event) => {
|
||||||
if (!self.Notification || self.Notification.permission !== "granted") {
|
if (!self.Notification || self.Notification.permission !== "granted") {
|
||||||
console.log("Notification permission not granted");
|
console.log("Notification permission not granted");
|
||||||
return;
|
return;
|
||||||
@ -28,7 +29,7 @@ self.addEventListener("push", (event) => {
|
|||||||
const data = event.data?.json() ?? {};
|
const data = event.data?.json() ?? {};
|
||||||
console.log("Received a push message", event, data);
|
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.");
|
console.log("Client already open, not showing notification.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user