fix: show leave site alert for instant meetings only (#13448)
* fix: leave site alert * fix: only use expiry time --------- Co-authored-by: Udit Takkar <udit222001@gmail.com>
This commit is contained in:
1 parent
63feb721ea
commit
00e96ac7ad
1 file changed
+11
-8
@@ -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,
|
||||
@@ -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}>
|
||||
|
||||
Reference in new issue
Block a user