mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-02-13 16:13:24 +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={
|
||||
notifPermission === 'denied' ? (
|
||||
<Text as="span" style={{ color: color.Critical.Main }} size="T200">
|
||||
{!Notification
|
||||
? 'Notifications are not supported by the system.'
|
||||
: 'Notification permission is blocked. Please allow notification permission from browser address bar.'}
|
||||
{'Notification' in window
|
||||
? 'Notification permission is blocked. Please allow notification permission from browser address bar.'
|
||||
: 'Notifications are not supported by the system.'}
|
||||
</Text>
|
||||
) : (
|
||||
<span>Show desktop notifications when message arrive.</span>
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import { useEffect, useState } from 'react';
|
||||
|
||||
export const getNotificationState = (): PermissionState => {
|
||||
try {
|
||||
if ('Notification' in window) {
|
||||
if (window.Notification.permission === 'default') {
|
||||
return 'prompt';
|
||||
}
|
||||
|
||||
return window.Notification.permission;
|
||||
} catch {
|
||||
return 'denied';
|
||||
}
|
||||
|
||||
return 'denied';
|
||||
};
|
||||
|
||||
export function usePermissionState(name: PermissionName, initialValue: PermissionState = 'prompt') {
|
||||
|
|
|
@ -219,9 +219,8 @@ export const syntaxErrorPosition = (error: SyntaxError): number | undefined => {
|
|||
};
|
||||
|
||||
export const notificationPermission = (permission: NotificationPermission) => {
|
||||
try {
|
||||
if ('Notification' in window) {
|
||||
return window.Notification.permission === permission;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue