diff --git a/apps/100ms-custom-app/src/App.jsx b/apps/100ms-custom-app/src/App.jsx index 42fd489094..bb769c615a 100644 --- a/apps/100ms-custom-app/src/App.jsx +++ b/apps/100ms-custom-app/src/App.jsx @@ -36,7 +36,7 @@ const App = () => { const { hmsActions } = hmsPrebuiltRef.current; hmsActions?.enableBeamSpeakerLabelsLogging?.(); hmsActions?.ignoreMessageTypes?.(['chat', 'EMOJI_REACTION']); - hmsActions?.setAppData?.('disableNotificiations', true); + hmsActions?.setAppData?.('disableNotifications', true); } }, [authToken, roomCode, isHeadless]); @@ -54,6 +54,19 @@ const App = () => { } }, [authToken, role, roomCode, roomId, subdomain]); + // Prompt for page refresh/tab close + useEffect(() => { + const confirmLeave = e => { + e.returnValue = 'Are you sure you want to leave?'; + }; + + window.addEventListener('beforeunload', confirmLeave); + + return () => { + window.removeEventListener('beforeunload', confirmLeave); + }; + }, []); + return ( +pa diff --git a/packages/react-sdk/src/primitives/HmsRoomProvider.ts b/packages/react-sdk/src/primitives/HmsRoomProvider.ts index 629573e641..4d5fb0a20d 100644 --- a/packages/react-sdk/src/primitives/HmsRoomProvider.ts +++ b/packages/react-sdk/src/primitives/HmsRoomProvider.ts @@ -111,11 +111,10 @@ export const HMSRoomProvider = { if (isBrowser && leaveOnUnload) { - const beforeUnloadCallback = () => providerProps.actions.leave(); - window.addEventListener('beforeunload', beforeUnloadCallback); - + const unloadCallback = () => providerProps.actions.leave(); + window.addEventListener('unload', unloadCallback); return () => { - window.removeEventListener('beforeunload', beforeUnloadCallback); + window.removeEventListener('unload', unloadCallback); }; } diff --git a/packages/roomkit-react/src/Prebuilt/common/constants.js b/packages/roomkit-react/src/Prebuilt/common/constants.js index ad1a903ec5..6b496c1f3f 100644 --- a/packages/roomkit-react/src/Prebuilt/common/constants.js +++ b/packages/roomkit-react/src/Prebuilt/common/constants.js @@ -44,7 +44,7 @@ export const APP_DATA = { pdfConfig: 'pdfConfig', minimiseInset: 'minimiseInset', activeScreensharePeerId: 'activeScreensharePeerId', - disableNotificiations: 'disableNotificiations', + disableNotifications: 'disableNotifications', }; export const UI_SETTINGS = { isAudioOnly: 'isAudioOnly', diff --git a/packages/roomkit-react/src/Prebuilt/components/AppData/AppData.jsx b/packages/roomkit-react/src/Prebuilt/components/AppData/AppData.jsx index d1ac7d1e6d..5580d028ff 100644 --- a/packages/roomkit-react/src/Prebuilt/components/AppData/AppData.jsx +++ b/packages/roomkit-react/src/Prebuilt/components/AppData/AppData.jsx @@ -65,7 +65,7 @@ const initialAppData = { [APP_DATA.authToken]: '', [APP_DATA.minimiseInset]: false, [APP_DATA.activeScreensharePeerId]: '', - [APP_DATA.disableNotificiations]: false, + [APP_DATA.disableNotifications]: false, }; export const AppData = React.memo(({ appDetails, tokenEndpoint }) => { diff --git a/packages/roomkit-react/src/Prebuilt/components/AppData/useUISettings.js b/packages/roomkit-react/src/Prebuilt/components/AppData/useUISettings.js index af672ba3d0..d468faeb4a 100644 --- a/packages/roomkit-react/src/Prebuilt/components/AppData/useUISettings.js +++ b/packages/roomkit-react/src/Prebuilt/components/AppData/useUISettings.js @@ -86,7 +86,7 @@ export const useSubscribedNotifications = notificationKey => { }; export const useIsNotificationDisabled = () => { - const notificationPreference = useHMSStore(selectAppDataByPath(APP_DATA.disableNotificiations)); + const notificationPreference = useHMSStore(selectAppDataByPath(APP_DATA.disableNotifications)); return notificationPreference; };