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 committed Oct 24, 2023
1 parent 545779c commit 1556adb
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 @@ -248,6 +248,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 = () => {
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.'
}
} else {
window.onbeforeunload = null
}
})
</script>

<style scoped>
Expand Down

0 comments on commit 1556adb

Please sign in to comment.