Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { Dialog, DialogContent } from "@calcom/ui";
import { Button } from "@calcom/ui";

const handleBeforeUnload = (event: BeforeUnloadEvent) => {
const message = "/o";
event.returnValue = message; // Standard for most browsers
return message; // For some older browsers
};

export const RedirectToInstantMeetingModal = ({
hasInstantMeetingTokenExpired,
bookingId,
Expand Down Expand Up @@ -47,19 +53,16 @@ export const RedirectToInstantMeetingModal = ({
};

useEffect(() => {
if (hasInstantMeetingTokenExpired) return;

const handleBeforeUnload = (event: BeforeUnloadEvent) => {
const message = "/o";
event.returnValue = message; // Standard for most browsers
return message; // For some older browsers
};
if (!expiryTime || hasInstantMeetingTokenExpired) {
window.removeEventListener("beforeunload", handleBeforeUnload);
return;
}

window.addEventListener("beforeunload", handleBeforeUnload);
return () => {
window.removeEventListener("beforeunload", handleBeforeUnload);
};
}, [hasInstantMeetingTokenExpired]);
}, [expiryTime, hasInstantMeetingTokenExpired]);

return (
<Dialog open={!!bookingId && !!expiryTime}>
Expand Down