revert timeline changes

This commit is contained in:
Henry Jameson 2022-04-10 17:47:54 +03:00
parent ce9fd04865
commit 2df48b1643

View file

@ -12,8 +12,6 @@ library.add(
faCog faCog
) )
const scroller = () => document.getElementById('content')
const Timeline = { const Timeline = {
props: [ props: [
'timeline', 'timeline',
@ -91,7 +89,7 @@ const Timeline = {
const credentials = store.state.users.currentUser.credentials const credentials = store.state.users.currentUser.credentials
const showImmediately = this.timeline.visibleStatuses.length === 0 const showImmediately = this.timeline.visibleStatuses.length === 0
scroller() && scroller().addEventListener('scroll', this.handleScroll) window.addEventListener('scroll', this.handleScroll)
if (store.state.api.fetchers[this.timelineName]) { return false } if (store.state.api.fetchers[this.timelineName]) { return false }
@ -113,7 +111,7 @@ const Timeline = {
setTimeout(this.determineVisibleStatuses, 250) setTimeout(this.determineVisibleStatuses, 250)
}, },
unmounted () { unmounted () {
scroller().removeEventListener('scroll', this.handleScroll) window.removeEventListener('scroll', this.handleScroll)
window.removeEventListener('keydown', this.handleShortKey) 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 })
@ -143,7 +141,7 @@ const Timeline = {
this.$store.commit('showNewStatuses', { timeline: this.timelineName }) this.$store.commit('showNewStatuses', { timeline: this.timelineName })
this.paused = false this.paused = false
} }
scroller().scrollTop = 0 window.scrollTop = 0
}, },
fetchOlderStatuses: throttle(function () { fetchOlderStatuses: throttle(function () {
const store = this.$store const store = this.$store
@ -231,8 +229,8 @@ const Timeline = {
} }
if (count > 0) { if (count > 0) {
// only 'stream' them when you're scrolled to the top // only 'stream' them when you're scrolled to the top
const doc = document.getElementById('content') const doc = document.documentElement
const top = (doc.scrollTop) - (doc.clientTop || 0) const top = (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)
if (top < 15 && if (top < 15 &&
!this.paused && !this.paused &&
!(this.unfocused && this.$store.getters.mergedConfig.pauseOnUnfocused) !(this.unfocused && this.$store.getters.mergedConfig.pauseOnUnfocused)