Skip to content

Commit

Permalink
Try to prevent user from closing Cockpit during video record
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl authored and patrickelectric committed Oct 26, 2023
1 parent f2219c4 commit 4e6b7bb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/components/mini-widgets/MiniVideoRecorder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,22 @@ watch(externalStreams, () => {
updateCurrentStream(savedStream)
}
})
// Try to prevent user from closing Cockpit when a stream is being recorded
watch(isRecording, () => {
if (!isRecording.value) {
window.onbeforeunload = null
return
}
window.onbeforeunload = () => {
const alertMsg = `
You have a video recording ongoing.
Remember to stop it before closing Cockpit, or the record will be lost.
`
Swal.fire({ text: alertMsg, icon: 'warning' })
return 'I hope the user does not click on the leave button.'
}
})
</script>

<style scoped>
Expand Down

0 comments on commit 4e6b7bb

Please sign in to comment.