Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prompt for page refresh, tab close #1987

Merged
merged 4 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion apps/100ms-custom-app/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand All @@ -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?';
raviteja83 marked this conversation as resolved.
Show resolved Hide resolved
};

window.addEventListener('beforeunload', confirmLeave);

return () => {
window.removeEventListener('beforeunload', confirmLeave);
};
}, []);

return (
<Flex
className="prebuilt-wrapper"
Expand Down
2 changes: 1 addition & 1 deletion apps/100ms-custom-app/src/assets/images/100ms_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions packages/react-sdk/src/primitives/HmsRoomProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,10 @@ export const HMSRoomProvider = <T extends HMSGenericTypes = { sessionStore: Reco

useEffect(() => {
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);
raviteja83 marked this conversation as resolved.
Show resolved Hide resolved
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/roomkit-react/src/Prebuilt/common/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const APP_DATA = {
pdfConfig: 'pdfConfig',
minimiseInset: 'minimiseInset',
activeScreensharePeerId: 'activeScreensharePeerId',
disableNotificiations: 'disableNotificiations',
disableNotifications: 'disableNotifications',
};
export const UI_SETTINGS = {
isAudioOnly: 'isAudioOnly',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
Loading