Update fetchMore functionality on profile page

- clean up from pinned Posts PR
This commit is contained in:
mattwr18 2019-10-23 09:41:31 +02:00
parent 015e9b9009
commit fda6f683d4

View File

@ -376,7 +376,7 @@ export default {
return uniqBy(items, field)
},
showMoreContributions() {
const { Post: PostQuery } = this.$apollo.queries
const { profilePagePosts: PostQuery } = this.$apollo.queries
if (!PostQuery) return // seems this can be undefined on subpages
this.offset += this.pageSize
@ -388,11 +388,14 @@ export default {
orderBy: 'createdAt_desc',
},
updateQuery: (previousResult, { fetchMoreResult }) => {
if (!fetchMoreResult || fetchMoreResult.Post.length < this.pageSize) {
if (!fetchMoreResult || fetchMoreResult.profilePagePosts.length < this.pageSize) {
this.hasMore = false
}
const result = Object.assign({}, previousResult, {
Post: [...previousResult.Post, ...fetchMoreResult.Post],
profilePagePosts: [
...previousResult.profilePagePosts,
...fetchMoreResult.profilePagePosts,
],
})
return result
},
@ -464,7 +467,7 @@ export default {
},
},
apollo: {
Post: {
profilePagePosts: {
query() {
return profilePagePosts(this.$i18n)
},