Skip to content

Commit

Permalink
fix: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
KaustubhKumar05 committed Aug 12, 2024
1 parent 774f96b commit 37336f9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/react-sdk/src/hooks/useAwayNotifications.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
// write a hook to use the MDN notifications API to show a notification when the user is away from the page
import { useCallback } from 'react';
import { selectLocalPeerRoleName } from '@100mslive/hms-video-store';
import { useHMSActions, useHMSVanillaStore } from '../primitives/HmsRoomProvider';
import { useHMSVanillaStore } from '../primitives/HmsRoomProvider';

// Do not prompt if preview is not available. Skips for beam
export const useAwayNotifications = () => {
const vanillaStore = useHMSVanillaStore();
const hmsActions = useHMSActions();
const requestPermission = useCallback(async () => {
if (!Notification || Notification?.permission === 'granted' || Notification?.permission === 'denied') {
return;
}
const unsubscribe = vanillaStore.subscribe(async role => {
if (role && role !== '__internal_recorder') {
hmsActions?.sendBroadcastMessage(role);
await Notification.requestPermission();
unsubscribe?.();
}
}, selectLocalPeerRoleName);
}, [vanillaStore, hmsActions]);
}, [vanillaStore]);

const showNotification = useCallback((title: string, options?: NotificationOptions) => {
if (
Expand Down

0 comments on commit 37336f9

Please sign in to comment.