mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
Check browser has notification capability
This commit is contained in:
parent
175bb9e5c7
commit
88416fcd54
@ -1,6 +1,8 @@
|
||||
class Notifications {
|
||||
constructor() {
|
||||
Notification.requestPermission();
|
||||
if (this.notifications_available) {
|
||||
Notification.requestPermission();
|
||||
}
|
||||
}
|
||||
|
||||
notifyTurn(player) {
|
||||
@ -11,10 +13,14 @@ class Notifications {
|
||||
}
|
||||
|
||||
notify(options) {
|
||||
if (!document.hasFocus()) {
|
||||
if (this.notifications_available && !document.hasFocus()) {
|
||||
new Notification("Chess", options);
|
||||
}
|
||||
}
|
||||
|
||||
get notifications_available() {
|
||||
window.Notification != undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export default Notifications;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user