fix missing check for Notification

This commit is contained in:
Ajay Bura 2025-02-10 15:27:24 +05:30
parent 95e28caf38
commit c4a132d4dd
3 changed files with 8 additions and 9 deletions

View file

@ -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>

View file

@ -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') {

View file

@ -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;
};