mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-10-18 14:13:21 +00:00
nope
This commit is contained in:
parent
d8340c4881
commit
72ed91ecc8
@ -17,32 +17,11 @@ if (self.location.host.indexOf('localhost') !== 0) {
|
||||
});
|
||||
}
|
||||
|
||||
function isClientFocused() {
|
||||
return clients.matchAll({
|
||||
type: 'window',
|
||||
includeUncontrolled: true
|
||||
}).then((windowClients) => {
|
||||
let clientIsFocused = false;
|
||||
|
||||
for (let i = 0; i < windowClients.length; i++) {
|
||||
const windowClient = windowClients[i];
|
||||
if (windowClient.focused) {
|
||||
clientIsFocused = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return clientIsFocused;
|
||||
});
|
||||
}
|
||||
|
||||
self.addEventListener('push', ev => {
|
||||
const data = ev.data.json();
|
||||
console.log('Got push', data);
|
||||
if (!isClientFocused()) {
|
||||
self.registration.showNotification(data.title || 'Hello, World!', {
|
||||
body: data.body || 'Hello, World!',
|
||||
icon: './img/icon128.png'
|
||||
});
|
||||
}
|
||||
self.registration.showNotification(data.title || 'Hello, World!', {
|
||||
body: data.body || 'Hello, World!',
|
||||
icon: './img/icon128.png'
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user