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 e8e9c69
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/components/mini-widgets/MiniVideoRecorder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,31 @@ watch(externalStreams, () => {
updateCurrentStream(savedStream)
}
})
// Try to prevent user from closing Cockpit when a stream is being recorded
const onBeforeUnloadHandler = (): string => {
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 clicl on the leave button.'
}
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 clicl on the leave button.'
}
} else {
window.onbeforeunload = null
}
})
</script>

<style scoped>
Expand Down

0 comments on commit e8e9c69

Please sign in to comment.