From e764158dcd60eb829da80416df1ea66d8fc39e1f Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Tue, 24 Oct 2023 16:21:33 -0300 Subject: [PATCH] Try to prevent user from closing Cockpit during video record --- src/components/mini-widgets/MiniVideoRecorder.vue | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/components/mini-widgets/MiniVideoRecorder.vue b/src/components/mini-widgets/MiniVideoRecorder.vue index acafe9b8e..0875e2804 100644 --- a/src/components/mini-widgets/MiniVideoRecorder.vue +++ b/src/components/mini-widgets/MiniVideoRecorder.vue @@ -248,6 +248,21 @@ watch(externalStreams, () => { updateCurrentStream(savedStream) } }) + +// Try to prevent user from closing Cockpit when a stream is being recorded +watch(isRecording, () => { + if (isRecording.value) { + window.onbeforeunload = () => { + Swal.fire({ + text: 'You have a video recording ongoing. Remember to stop it before closing Cockpit, or the record will be lost.', + icon: 'warning', + }) + return 'bad idea' + } + } else { + window.onbeforeunload = null + } +})