aboutsummaryrefslogtreecommitdiff
path: root/src/components/timeline/timeline.js
diff options
context:
space:
mode:
authorEdijs <iamedijs@hotmail.com>2019-02-17 14:37:24 -0700
committerEdijs <iamedijs@hotmail.com>2019-02-17 14:37:24 -0700
commit0d2922afb3bcfcdcc439f158d147db1f08d995c7 (patch)
tree78a82af6a5c418eb1d9ad9d90299f292b54a2b57 /src/components/timeline/timeline.js
parent642b0be0b2c82e7c9c1bb45c50e60b2d3b4090f8 (diff)
Remove event listener when component destroy
Diffstat (limited to 'src/components/timeline/timeline.js')
-rw-r--r--src/components/timeline/timeline.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js
index a8a3495a..d7f7029e 100644
--- a/src/components/timeline/timeline.js
+++ b/src/components/timeline/timeline.js
@@ -67,16 +67,18 @@ const Timeline = {
document.addEventListener('visibilitychange', this.handleVisibilityChange, false)
this.unfocused = document.hidden
}
- window.addEventListener('keydown', e => {
- if (e.key === '.') this.showNewStatuses()
- })
+ window.addEventListener('keydown', this.handleShortKey)
},
destroyed () {
window.removeEventListener('scroll', this.scrollLoad)
+ window.removeEventListener('keydown', this.handleShortKey)
if (typeof document.hidden !== 'undefined') document.removeEventListener('visibilitychange', this.handleVisibilityChange, false)
this.$store.commit('setLoading', { timeline: this.timelineName, value: false })
},
methods: {
+ handleShortKey (e) {
+ if (e.key === '.') this.showNewStatuses()
+ },
showNewStatuses () {
if (this.timeline.flushMarker !== 0) {
this.$store.commit('clearTimeline', { timeline: this.timelineName })