Add Notification workaround for Chrome on Android

Closes: https://todo.sr.ht/~emersion/gamja/78
This commit is contained in:
Simon Ser 2021-06-10 17:01:26 +02:00
parent a952742d86
commit 63773f99ee
2 changed files with 50 additions and 22 deletions

View file

@ -306,6 +306,21 @@ class FoldGroup extends Component {
}
}
// Workaround for https://bugs.chromium.org/p/chromium/issues/detail?id=481856
var notificationsSupported = false;
if (window.Notification) {
notificationsSupported = true;
if (Notification.permission === "default") {
try {
new Notification("");
} catch (err) {
if (err.name === "TypeError") {
notificationsSupported = false;
}
}
}
}
class NotificationNagger extends Component {
state = { nag: false };
@ -318,7 +333,7 @@ class NotificationNagger extends Component {
}
shouldNag() {
return window.Notification && Notification.permission !== "granted" && Notification.permission !== "denied";
return notificationsSupported && Notification.permission === "default";
}
handleClick(event) {