Skip to content

Commit

Permalink
fix Notification check
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbura committed Feb 10, 2025
1 parent f3ad901 commit e3efde0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 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 => {
if (!window.Notification) {
return 'denied';
}
if ('Notification' in window) {
if (window.Notification.permission === 'default') {
return 'prompt';
}

if (window.Notification.permission === 'default') {
return 'prompt';
return window.Notification.permission;
}

return window.Notification.permission;
return 'denied';
};

export function usePermissionState(name: PermissionName, initialValue: PermissionState = 'prompt') {
Expand Down
2 changes: 1 addition & 1 deletion src/app/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export const syntaxErrorPosition = (error: SyntaxError): number | undefined => {
};

export const notificationPermission = (permission: NotificationPermission) => {
if (window.Notification) {
if ('Notification' in window) {
return window.Notification.permission === permission;
}
return false;
Expand Down

0 comments on commit e3efde0

Please sign in to comment.