From 774f96b0b71fc4f581b07a4fb31569501419941e Mon Sep 17 00:00:00 2001 From: KaustubhKumar05 Date: Mon, 12 Aug 2024 15:39:24 +0530 Subject: [PATCH] fix: send role in chat --- packages/react-sdk/src/hooks/useAwayNotifications.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/react-sdk/src/hooks/useAwayNotifications.ts b/packages/react-sdk/src/hooks/useAwayNotifications.ts index bc65175846..09961d0c49 100644 --- a/packages/react-sdk/src/hooks/useAwayNotifications.ts +++ b/packages/react-sdk/src/hooks/useAwayNotifications.ts @@ -1,22 +1,24 @@ // 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 { useHMSVanillaStore } from '../primitives/HmsRoomProvider'; +import { useHMSActions, 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') { + 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]); + }, [vanillaStore, hmsActions]); const showNotification = useCallback((title: string, options?: NotificationOptions) => { if (