diff --git a/client/components/App.vue b/client/components/App.vue index f0ed4d61..f667588d 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -109,13 +109,10 @@ export default { activeChannel: Object, networks: Array, }, - methods: { - isPublic: () => document.body.classList.contains("public"), - }, mounted() { // Make a single throttled resize listener available to all components this.debouncedResize = throttle(() => { - this.$root.$emit('resize'); + this.$root.$emit("resize"); }, 100); window.addEventListener("resize", this.debouncedResize, {passive: true}); @@ -123,5 +120,8 @@ export default { beforeDestroy() { window.removeEventListener("resize", this.debouncedResize); }, + methods: { + isPublic: () => document.body.classList.contains("public"), + }, }; diff --git a/client/components/LinkPreview.vue b/client/components/LinkPreview.vue index 7fbbb1d0..29b802f7 100644 --- a/client/components/LinkPreview.vue +++ b/client/components/LinkPreview.vue @@ -147,16 +147,17 @@ export default { return; } - this.resizeListener = () => {this.handleResize()}; - this.$root.$on('resize', this.resizeListener); + this.$root.$on("resize", this.handleResize); this.onPreviewUpdate(); }, + beforeDestroy() { + this.$root.$off("resize", this.handleResize); + }, destroyed() { // Let this preview go through load/canplay events again, // Otherwise the browser can cause a resize on video elements this.link.canDisplay = false; - this.$root.$off('resize', this.resizeListener); }, methods: { onPreviewUpdate() { diff --git a/client/components/MessageList.vue b/client/components/MessageList.vue index d15c1b72..3a15a351 100644 --- a/client/components/MessageList.vue +++ b/client/components/MessageList.vue @@ -187,8 +187,7 @@ export default { this.$refs.chat.addEventListener("scroll", this.debouncedScroll, {passive: true}); - this.resizeListener = () => {this.handleResize()} - this.$root.$on('resize', this.resizeListener); + this.$root.$on("resize", this.handleResize); this.$nextTick(() => { if (this.historyObserver) { @@ -197,7 +196,7 @@ export default { }); }, beforeDestroy() { - this.$root.$off('resize', this.resizeListener); + this.$root.$off("resize", this.handleResize); this.$refs.chat.removeEventListener("scroll", this.debouncedScroll); }, destroyed() {