Skip to content

Commit

Permalink
fix missing check for Notification
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbura committed Feb 10, 2025
1 parent 95e28ca commit c4a132d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/app/features/settings/notifications/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 3 additions & 3 deletions src/app/hooks/usePermission.ts
Original file line number Diff line number Diff line change
@@ -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') {
Expand Down
5 changes: 2 additions & 3 deletions src/app/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit c4a132d

Please sign in to comment.