Commit d0ff087c authored by anton's avatar anton

Always remove event handlers in beforeDestroy

parent 9c2679ae
Pipeline #57145 passed with stage
in 1 minute and 24 seconds
......@@ -119,6 +119,10 @@ export default {
this.$root.$on('video-time-changed', this.onMediaTimeChanged)
this.$root.$on('grid-datetime', this.onGridDateTime)
},
beforeDestroy () {
this.$root.$off('video-time-changed', this.onMediaTimeChanged)
this.$root.$off('grid-datetime', this.onGridDateTime)
},
computed: {
videoUuid () {
return this.cell ? this.cell.id : undefined
......
......@@ -71,21 +71,27 @@
// Show the player after 2s if the canPlay event does not fire
setTimeout(() => { _this.showPlayer = true }, 2000)
}
const _this = this
this.$root.$on('grid-datetime', datetime => {
console.debug('CellMedia: received grid-datetime', datetime.toISO())
_this.setPlayerTimeFromDateTime(datetime)
})
this.$root.$on('annotation-trigger', (annotation, annotationGlobalTime) => {
if (!_this.video) return
if (_this.video.target && annotation.target.id === _this.video.target.id) {
console.debug('CellMedia: received annotation-trigger', annotation.id, annotationGlobalTime.toISO())
_this.setPlayerTimeFromDateTime(annotationGlobalTime)
}
})
this.$root.$on('grid-datetime', this.onGridDateTime)
this.$root.$on('annotation-trigger', this.onAnnotationTrigger)
}
},
beforeDestroy () {
this.$root.$off('grid-datetime', this.onGridDateTime)
this.$root.$off('annotation-trigger', this.onAnnotationTrigger)
},
methods: {
onGridDateTime (datetime) {
console.debug('CellMedia: received grid-datetime', datetime.toISO())
this.setPlayerTimeFromDateTime(datetime)
},
onAnnotationTrigger (annotation, annotationGlobalTime) {
if (!this.video) return
if (this.video.target && annotation.target.id === this.video.target.id) {
console.debug('CellMedia: received annotation-trigger', annotation.id, annotationGlobalTime.toISO())
this.setPlayerTimeFromDateTime(annotationGlobalTime)
}
},
fauxMedia () {
this.video = {
body: {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment