Skip to content

Commit

Permalink
Fix notification async behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
JanneMattila committed Jun 30, 2023
1 parent 22880fc commit 2beb55d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/MyChess.Client/wwwroot/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,15 @@ self.addEventListener('push', (event) => {

event.waitUntil(showNotification);

const clientList = await clients.matchAll({
clients.matchAll({
type: "window", includeUncontrolled: true
});
if (clientList.length > 0) {
let client = clientList[0];
}).then((clientList) => {
for (let i = 0; i < clientList.length; i++) {
if (clientList[i].focused) {
client = clientList[i];
clientList[i].postMessage(notificationData);
}
}
client.postMessage(notificationData);
}
});
});

self.addEventListener('notificationclick', (event) => {
Expand Down

0 comments on commit 2beb55d

Please sign in to comment.