|
|
@ -3,6 +3,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
const checkNotificationPromise = () => {
|
|
|
|
const checkNotificationPromise = () => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
// eslint-disable-next-line promise/catch-or-return
|
|
|
|
Notification.requestPermission().then();
|
|
|
|
Notification.requestPermission().then();
|
|
|
|
} catch(e) {
|
|
|
|
} catch(e) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -22,7 +23,7 @@ const handlePermission = (permission, callback) => {
|
|
|
|
|
|
|
|
|
|
|
|
export const requestNotificationPermission = (callback) => {
|
|
|
|
export const requestNotificationPermission = (callback) => {
|
|
|
|
if (checkNotificationPromise()) {
|
|
|
|
if (checkNotificationPromise()) {
|
|
|
|
Notification.requestPermission().then((permission) => handlePermission(permission, callback));
|
|
|
|
Notification.requestPermission().then((permission) => handlePermission(permission, callback)).catch(console.warn);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Notification.requestPermission((permission) => handlePermission(permission, callback));
|
|
|
|
Notification.requestPermission((permission) => handlePermission(permission, callback));
|
|
|
|
}
|
|
|
|
}
|
|
|
|