fix(calls): warn before unload during a joined call
Register beforeunload while joined so Ctrl+R / tab close prompts instead of silently dropping the call. Also removes the setPipMode effect (#59). Fixes #58 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
This commit is contained in:
@@ -631,6 +631,22 @@ function CallUtils({ embed, joined }: { embed: CallEmbed; joined: boolean }) {
|
|||||||
}, [setCallEmbed]),
|
}, [setCallEmbed]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// [Gitea #58] Warn before an accidental tab close/reload drops the user out
|
||||||
|
// of a live call. Only armed while actually joined, and torn down on
|
||||||
|
// hangup/dispose since this effect re-runs when `joined` flips back to false.
|
||||||
|
useEffect(() => {
|
||||||
|
if (!joined) return undefined;
|
||||||
|
const onBeforeUnload = (event: BeforeUnloadEvent) => {
|
||||||
|
event.preventDefault();
|
||||||
|
// Legacy browsers require returnValue to be set to show the prompt.
|
||||||
|
event.returnValue = '';
|
||||||
|
};
|
||||||
|
window.addEventListener('beforeunload', onBeforeUnload);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('beforeunload', onBeforeUnload);
|
||||||
|
};
|
||||||
|
}, [joined]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -735,12 +751,6 @@ export function CallEmbedProvider({ children }: CallEmbedProviderProps) {
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Sync pip mode into CallControl so it can adjust behavior accordingly
|
|
||||||
useEffect(() => {
|
|
||||||
if (!callEmbed) return;
|
|
||||||
callEmbed.control.setPipMode(!!pipMode);
|
|
||||||
}, [pipMode, callEmbed]);
|
|
||||||
|
|
||||||
// When entering pip with screenshare active (or screenshare starts while in pip),
|
// When entering pip with screenshare active (or screenshare starts while in pip),
|
||||||
// enable spotlight so the screenshare fills the pip window.
|
// enable spotlight so the screenshare fills the pip window.
|
||||||
// When screenshare ends, release the spotlight we auto-enabled.
|
// When screenshare ends, release the spotlight we auto-enabled.
|
||||||
|
|||||||
Reference in New Issue
Block a user