The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/hooks/notification/useNotificationAllowed.ts

19 lines
497 B

import { useCallback, useSyncExternalStore } from 'react';
import { notificationManager } from '../../lib/notificationManager';
export const useNotificationAllowed = (): boolean => {
const allowed = useSyncExternalStore(
useCallback(
(callback): (() => void) =>
notificationManager.on('change', () => {
notificationManager.allowed = Notification.permission === 'granted';
callback();
}),
[],
),
(): boolean => notificationManager.allowed,
);
return allowed;
};