Fix scroll position when lazyFetchTimeline at bottom of timeline

This commit is contained in:
AkiraFukushima 2021-09-14 02:02:51 +09:00
parent f47313041e
commit 2307438745
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
9 changed files with 139 additions and 29 deletions

View File

@ -175,6 +175,17 @@ export default {
) {
this.$store
.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(() => {
this.$message({
message: this.$t('message.timeline_fetch_error'),

View File

@ -178,10 +178,28 @@ export default {
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
!this.lazyloading
) {
this.$store.dispatch('TimelineSpace/Contents/Hashtag/Tag/lazyFetchTimeline', {
tag: this.tag,
status: this.timeline[this.timeline.length - 1]
})
this.$store
.dispatch('TimelineSpace/Contents/Hashtag/Tag/lazyFetchTimeline', {
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) {

View File

@ -172,12 +172,25 @@ export default {
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
!this.lazyloading
) {
this.$store.dispatch('TimelineSpace/Contents/Home/lazyFetchTimeline', this.timeline[this.timeline.length - 1]).catch(() => {
this.$message({
message: this.$t('message.timeline_fetch_error'),
type: 'error'
this.$store
.dispatch('TimelineSpace/Contents/Home/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
.then(statuses => {
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) {

View File

@ -179,10 +179,28 @@ export default {
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
!this.lazyloading
) {
this.$store.dispatch('TimelineSpace/Contents/Lists/Show/lazyFetchTimeline', {
list_id: this.list_id,
status: this.timeline[this.timeline.length - 1]
})
this.$store
.dispatch('TimelineSpace/Contents/Lists/Show/lazyFetchTimeline', {
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) {

View File

@ -178,12 +178,25 @@ export default {
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
!this.lazyloading
) {
this.$store.dispatch('TimelineSpace/Contents/Local/lazyFetchTimeline', this.timeline[this.timeline.length - 1]).catch(() => {
this.$message({
message: this.$t('message.timeline_fetch_error'),
type: 'error'
this.$store
.dispatch('TimelineSpace/Contents/Local/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
.then(statuses => {
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) {
this.$store.commit('TimelineSpace/Contents/Local/changeHeading', false)

View File

@ -151,12 +151,25 @@ export default {
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
!this.lazyloading
) {
this.$store.dispatch('TimelineSpace/Contents/Mentions/lazyFetchMentions', this.mentions[this.mentions.length - 1]).catch(() => {
this.$message({
message: this.$t('message.timeline_fetch_error'),
type: 'error'
this.$store
.dispatch('TimelineSpace/Contents/Mentions/lazyFetchMentions', this.mentions[this.mentions.length - 1])
.then(statuses => {
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) {

View File

@ -163,6 +163,17 @@ export default {
'TimelineSpace/Contents/Notifications/lazyFetchNotifications',
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(() => {
this.$message({
message: this.$t('message.notification_fetch_error'),

View File

@ -180,12 +180,25 @@ export default {
event.target.clientHeight + event.target.scrollTop >= document.getElementById('scroller').scrollHeight - 10 &&
!this.lazyloading
) {
this.$store.dispatch('TimelineSpace/Contents/Public/lazyFetchTimeline', this.timeline[this.timeline.length - 1]).catch(() => {
this.$message({
message: this.$t('message.timeline_fetch_error'),
type: 'error'
this.$store
.dispatch('TimelineSpace/Contents/Public/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
.then(statuses => {
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) {

View File

@ -131,7 +131,7 @@ const actions: ActionTree<TagState, RootState> = {
resolve(null)
})
},
lazyFetchTimeline: async ({ state, commit, rootState }, loadPosition: LoadPositionWithTag) => {
lazyFetchTimeline: async ({ state, commit, rootState }, loadPosition: LoadPositionWithTag): Promise<Array<Entity.Status> | null> => {
if (state.lazyLoading) {
return Promise.resolve(null)
}