mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-02-22 21:23:09 +01:00
fix missing check for Notification
This commit is contained in:
parent
95e28caf38
commit
c4a132d4dd
3 changed files with 8 additions and 9 deletions
|
@ -38,9 +38,9 @@ function SystemNotification() {
|
||||||
description={
|
description={
|
||||||
notifPermission === 'denied' ? (
|
notifPermission === 'denied' ? (
|
||||||
<Text as="span" style={{ color: color.Critical.Main }} size="T200">
|
<Text as="span" style={{ color: color.Critical.Main }} size="T200">
|
||||||
{!Notification
|
{'Notification' in window
|
||||||
? 'Notifications are not supported by the system.'
|
? 'Notification permission is blocked. Please allow notification permission from browser address bar.'
|
||||||
: 'Notification permission is blocked. Please allow notification permission from browser address bar.'}
|
: 'Notifications are not supported by the system.'}
|
||||||
</Text>
|
</Text>
|
||||||
) : (
|
) : (
|
||||||
<span>Show desktop notifications when message arrive.</span>
|
<span>Show desktop notifications when message arrive.</span>
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
export const getNotificationState = (): PermissionState => {
|
export const getNotificationState = (): PermissionState => {
|
||||||
try {
|
if ('Notification' in window) {
|
||||||
if (window.Notification.permission === 'default') {
|
if (window.Notification.permission === 'default') {
|
||||||
return 'prompt';
|
return 'prompt';
|
||||||
}
|
}
|
||||||
|
|
||||||
return window.Notification.permission;
|
return window.Notification.permission;
|
||||||
} catch {
|
|
||||||
return 'denied';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 'denied';
|
||||||
};
|
};
|
||||||
|
|
||||||
export function usePermissionState(name: PermissionName, initialValue: PermissionState = 'prompt') {
|
export function usePermissionState(name: PermissionName, initialValue: PermissionState = 'prompt') {
|
||||||
|
|
|
@ -219,9 +219,8 @@ export const syntaxErrorPosition = (error: SyntaxError): number | undefined => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const notificationPermission = (permission: NotificationPermission) => {
|
export const notificationPermission = (permission: NotificationPermission) => {
|
||||||
try {
|
if ('Notification' in window) {
|
||||||
return window.Notification.permission === permission;
|
return window.Notification.permission === permission;
|
||||||
} catch {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue