Merge pull request #2748 from h3poteto/fix/bottom-scroll
Fix scroll position when lazyFetchTimeline at bottom of timeline
This commit is contained in:
commit
275e96cf6c
|
@ -175,6 +175,17 @@ export default {
|
||||||
) {
|
) {
|
||||||
this.$store
|
this.$store
|
||||||
.dispatch('TimelineSpace/Contents/DirectMessages/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
.dispatch('TimelineSpace/Contents/DirectMessages/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
||||||
|
.then(statuses => {
|
||||||
|
if (statuses === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (statuses.length > 0) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/DirectMessages/changeScrolling', true)
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/DirectMessages/changeScrolling', false)
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
|
|
|
@ -178,10 +178,28 @@ export default {
|
||||||
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
||||||
!this.lazyloading
|
!this.lazyloading
|
||||||
) {
|
) {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/lazyFetchTimeline', {
|
this.$store
|
||||||
tag: this.tag,
|
.dispatch('TimelineSpace/Contents/Hashtag/Tag/lazyFetchTimeline', {
|
||||||
status: this.timeline[this.timeline.length - 1]
|
tag: this.tag,
|
||||||
})
|
status: this.timeline[this.timeline.length - 1]
|
||||||
|
})
|
||||||
|
.then(statuses => {
|
||||||
|
if (statuses === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (statuses.length > 0) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/changeScrolling', true)
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Hashtag/Tag/changeScrolling', false)
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.target.scrollTop > 10 && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
|
|
|
@ -172,12 +172,25 @@ export default {
|
||||||
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
||||||
!this.lazyloading
|
!this.lazyloading
|
||||||
) {
|
) {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Home/lazyFetchTimeline', this.timeline[this.timeline.length - 1]).catch(() => {
|
this.$store
|
||||||
this.$message({
|
.dispatch('TimelineSpace/Contents/Home/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
.then(statuses => {
|
||||||
type: 'error'
|
if (statuses === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (statuses.length > 0) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Home/changeScrolling', true)
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Home/changeScrolling', false)
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.target.scrollTop > 10 && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
|
|
|
@ -179,10 +179,28 @@ export default {
|
||||||
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
||||||
!this.lazyloading
|
!this.lazyloading
|
||||||
) {
|
) {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Lists/Show/lazyFetchTimeline', {
|
this.$store
|
||||||
list_id: this.list_id,
|
.dispatch('TimelineSpace/Contents/Lists/Show/lazyFetchTimeline', {
|
||||||
status: this.timeline[this.timeline.length - 1]
|
list_id: this.list_id,
|
||||||
})
|
status: this.timeline[this.timeline.length - 1]
|
||||||
|
})
|
||||||
|
.then(statuses => {
|
||||||
|
if (statuses === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (statuses.length > 0) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Lists/Show/changeScrolling', true)
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Lists/Show/changeScrolling', false)
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.target.scrollTop > 10 && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
|
|
|
@ -178,12 +178,25 @@ export default {
|
||||||
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
||||||
!this.lazyloading
|
!this.lazyloading
|
||||||
) {
|
) {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Local/lazyFetchTimeline', this.timeline[this.timeline.length - 1]).catch(() => {
|
this.$store
|
||||||
this.$message({
|
.dispatch('TimelineSpace/Contents/Local/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
.then(statuses => {
|
||||||
type: 'error'
|
if (statuses === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (statuses.length > 0) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Local/changeScrolling', true)
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Local/changeScrolling', false)
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
if (event.target.scrollTop > 10 && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
this.$store.commit('TimelineSpace/Contents/Local/changeHeading', false)
|
this.$store.commit('TimelineSpace/Contents/Local/changeHeading', false)
|
||||||
|
|
|
@ -151,12 +151,25 @@ export default {
|
||||||
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
||||||
!this.lazyloading
|
!this.lazyloading
|
||||||
) {
|
) {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Mentions/lazyFetchMentions', this.mentions[this.mentions.length - 1]).catch(() => {
|
this.$store
|
||||||
this.$message({
|
.dispatch('TimelineSpace/Contents/Mentions/lazyFetchMentions', this.mentions[this.mentions.length - 1])
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
.then(statuses => {
|
||||||
type: 'error'
|
if (statuses === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (statuses.length > 0) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Mentions/changeScrolling', true)
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Mentions/changeScrolling', false)
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.target.scrollTop > 10 && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
|
|
|
@ -163,6 +163,17 @@ export default {
|
||||||
'TimelineSpace/Contents/Notifications/lazyFetchNotifications',
|
'TimelineSpace/Contents/Notifications/lazyFetchNotifications',
|
||||||
this.handledNotifications[this.handledNotifications.length - 1]
|
this.handledNotifications[this.handledNotifications.length - 1]
|
||||||
)
|
)
|
||||||
|
.then(statuses => {
|
||||||
|
if (statuses === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (statuses.length > 0) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Notifications/changeScrolling', true)
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Notifications/changeScrolling', false)
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.notification_fetch_error'),
|
message: this.$t('message.notification_fetch_error'),
|
||||||
|
|
|
@ -180,12 +180,25 @@ export default {
|
||||||
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
|
||||||
!this.lazyloading
|
!this.lazyloading
|
||||||
) {
|
) {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Public/lazyFetchTimeline', this.timeline[this.timeline.length - 1]).catch(() => {
|
this.$store
|
||||||
this.$message({
|
.dispatch('TimelineSpace/Contents/Public/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
||||||
message: this.$t('message.timeline_fetch_error'),
|
.then(statuses => {
|
||||||
type: 'error'
|
if (statuses === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (statuses.length > 0) {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Public/changeScrolling', true)
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$store.commit('TimelineSpace/Contents/Public/changeScrolling', false)
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$message({
|
||||||
|
message: this.$t('message.timeline_fetch_error'),
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.target.scrollTop > 10 && this.heading) {
|
if (event.target.scrollTop > 10 && this.heading) {
|
||||||
|
|
|
@ -131,7 +131,7 @@ const actions: ActionTree<TagState, RootState> = {
|
||||||
resolve(null)
|
resolve(null)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
lazyFetchTimeline: async ({ state, commit, rootState }, loadPosition: LoadPositionWithTag) => {
|
lazyFetchTimeline: async ({ state, commit, rootState }, loadPosition: LoadPositionWithTag): Promise<Array<Entity.Status> | null> => {
|
||||||
if (state.lazyLoading) {
|
if (state.lazyLoading) {
|
||||||
return Promise.resolve(null)
|
return Promise.resolve(null)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue