feat(bs): add beforeunload to prevent accidental closings

This commit is contained in:
2026-04-29 23:27:28 +02:00
parent 6701090c7a
commit d5aa3217ac

View File

@@ -87,6 +87,23 @@ export default function Page() {
}
}, [isSessionActive, ownedChannels, selectedChannel]);
useEffect(() => {
if (!isLive) {
return;
}
const handleBeforeUnload = (event: BeforeUnloadEvent) => {
event.preventDefault();
event.returnValue = '';
};
window.addEventListener('beforeunload', handleBeforeUnload);
return () => {
window.removeEventListener('beforeunload', handleBeforeUnload);
};
}, [isLive]);
const statusLabel = isLive
? 'LIVE'
: isSwitchingSource