forked from AkkomaGang/akkoma-fe
Remove event listener when component destroy
This commit is contained in:
parent
642b0be0b2
commit
0d2922afb3
1 changed files with 5 additions and 3 deletions
|
@ -67,16 +67,18 @@ const Timeline = {
|
||||||
document.addEventListener('visibilitychange', this.handleVisibilityChange, false)
|
document.addEventListener('visibilitychange', this.handleVisibilityChange, false)
|
||||||
this.unfocused = document.hidden
|
this.unfocused = document.hidden
|
||||||
}
|
}
|
||||||
window.addEventListener('keydown', e => {
|
window.addEventListener('keydown', this.handleShortKey)
|
||||||
if (e.key === '.') this.showNewStatuses()
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
destroyed () {
|
destroyed () {
|
||||||
window.removeEventListener('scroll', this.scrollLoad)
|
window.removeEventListener('scroll', this.scrollLoad)
|
||||||
|
window.removeEventListener('keydown', this.handleShortKey)
|
||||||
if (typeof document.hidden !== 'undefined') document.removeEventListener('visibilitychange', this.handleVisibilityChange, false)
|
if (typeof document.hidden !== 'undefined') document.removeEventListener('visibilitychange', this.handleVisibilityChange, false)
|
||||||
this.$store.commit('setLoading', { timeline: this.timelineName, value: false })
|
this.$store.commit('setLoading', { timeline: this.timelineName, value: false })
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleShortKey (e) {
|
||||||
|
if (e.key === '.') this.showNewStatuses()
|
||||||
|
},
|
||||||
showNewStatuses () {
|
showNewStatuses () {
|
||||||
if (this.timeline.flushMarker !== 0) {
|
if (this.timeline.flushMarker !== 0) {
|
||||||
this.$store.commit('clearTimeline', { timeline: this.timelineName })
|
this.$store.commit('clearTimeline', { timeline: this.timelineName })
|
||||||
|
|
Loading…
Reference in a new issue