From 8ce513ed09124fa0183943c359950f49ebcf2f89 Mon Sep 17 00:00:00 2001 From: shpuld Date: Thu, 31 Jan 2019 21:11:28 +0200 Subject: initial draft for follows/following pagination --- src/components/user_profile/user_profile.vue | 1 + 1 file changed, 1 insertion(+) (limited to 'src/components/user_profile/user_profile.vue') diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue index f9b964ce..baf6aef6 100644 --- a/src/components/user_profile/user_profile.vue +++ b/src/components/user_profile/user_profile.vue @@ -7,6 +7,7 @@
+
-- cgit v1.2.3-70-g09d2 From dbb16d56e29b8a32fb7c1a7af56a7953f571cdb4 Mon Sep 17 00:00:00 2001 From: shpuld Date: Sat, 2 Feb 2019 22:29:10 +0200 Subject: follows/followers pagination ready for review --- src/components/followers_list/followers_list.js | 61 +++++++++++++++++ src/components/followers_list/followers_list.vue | 12 ++++ src/components/friends_list/friends_list.js | 61 +++++++++++++++++ src/components/friends_list/friends_list.vue | 12 ++++ src/components/user_card/user_card.vue | 4 +- src/components/user_profile/user_profile.js | 76 +++++++--------------- src/components/user_profile/user_profile.vue | 9 +-- src/modules/users.js | 66 +++++++++++++++---- .../user_profile_link_generator.js | 2 +- 9 files changed, 228 insertions(+), 75 deletions(-) create mode 100644 src/components/followers_list/followers_list.js create mode 100644 src/components/followers_list/followers_list.vue create mode 100644 src/components/friends_list/friends_list.js create mode 100644 src/components/friends_list/friends_list.vue (limited to 'src/components/user_profile/user_profile.vue') diff --git a/src/components/followers_list/followers_list.js b/src/components/followers_list/followers_list.js new file mode 100644 index 00000000..13aace18 --- /dev/null +++ b/src/components/followers_list/followers_list.js @@ -0,0 +1,61 @@ +import UserCard from '../user_card/user_card.vue' + +const FollowersList = { + data () { + return { + loading: false, + bottomedOut: false, + error: false + } + }, + props: ['userId'], + created () { + window.addEventListener('scroll', this.scrollLoad) + if (this.user.followers.length === 0) { + this.fetchFollowers() + } + }, + destroyed () { + window.removeEventListener('scroll', this.scrollLoad) + this.$store.dispatch('clearFriendsAndFollowers', this.userId) + }, + computed: { + user () { + return this.$store.getters.userById(this.userId) + }, + followers () { + return this.user.followers + } + }, + methods: { + fetchFollowers () { + if (!this.loading) { + this.loading = true + this.$store.dispatch('addFollowers', this.userId).then(followers => { + this.error = false + this.loading = false + this.bottomedOut = followers.length === 0 + }).catch(() => { + this.error = true + this.loading = false + }) + } + }, + scrollLoad (e) { + const bodyBRect = document.body.getBoundingClientRect() + const height = Math.max(bodyBRect.height, -(bodyBRect.y)) + if (this.loading === false && + this.bottomedOut === false && + this.$el.offsetHeight > 0 && + (window.innerHeight + window.pageYOffset) >= (height - 750) + ) { + this.fetchFollowers() + } + } + }, + components: { + UserCard + } +} + +export default FollowersList diff --git a/src/components/followers_list/followers_list.vue b/src/components/followers_list/followers_list.vue new file mode 100644 index 00000000..b6bd35e1 --- /dev/null +++ b/src/components/followers_list/followers_list.vue @@ -0,0 +1,12 @@ + + + + + diff --git a/src/components/followers_list/followers_list.js b/src/components/followers_list/followers_list.js deleted file mode 100644 index 13aace18..00000000 --- a/src/components/followers_list/followers_list.js +++ /dev/null @@ -1,61 +0,0 @@ -import UserCard from '../user_card/user_card.vue' - -const FollowersList = { - data () { - return { - loading: false, - bottomedOut: false, - error: false - } - }, - props: ['userId'], - created () { - window.addEventListener('scroll', this.scrollLoad) - if (this.user.followers.length === 0) { - this.fetchFollowers() - } - }, - destroyed () { - window.removeEventListener('scroll', this.scrollLoad) - this.$store.dispatch('clearFriendsAndFollowers', this.userId) - }, - computed: { - user () { - return this.$store.getters.userById(this.userId) - }, - followers () { - return this.user.followers - } - }, - methods: { - fetchFollowers () { - if (!this.loading) { - this.loading = true - this.$store.dispatch('addFollowers', this.userId).then(followers => { - this.error = false - this.loading = false - this.bottomedOut = followers.length === 0 - }).catch(() => { - this.error = true - this.loading = false - }) - } - }, - scrollLoad (e) { - const bodyBRect = document.body.getBoundingClientRect() - const height = Math.max(bodyBRect.height, -(bodyBRect.y)) - if (this.loading === false && - this.bottomedOut === false && - this.$el.offsetHeight > 0 && - (window.innerHeight + window.pageYOffset) >= (height - 750) - ) { - this.fetchFollowers() - } - } - }, - components: { - UserCard - } -} - -export default FollowersList diff --git a/src/components/followers_list/followers_list.vue b/src/components/followers_list/followers_list.vue deleted file mode 100644 index b6bd35e1..00000000 --- a/src/components/followers_list/followers_list.vue +++ /dev/null @@ -1,12 +0,0 @@ - - -