diff --git a/src/components/followers_list/followers_list.js b/src/components/follow_list/follow_list.js similarity index 69% rename from src/components/followers_list/followers_list.js rename to src/components/follow_list/follow_list.js index 13aace18..6d00eb94 100644 --- a/src/components/followers_list/followers_list.js +++ b/src/components/follow_list/follow_list.js @@ -1,6 +1,6 @@ import UserCard from '../user_card/user_card.vue' -const FollowersList = { +const FollowList = { data () { return { loading: false, @@ -8,11 +8,11 @@ const FollowersList = { error: false } }, - props: ['userId'], + props: ['userId', 'showFollowers'], created () { window.addEventListener('scroll', this.scrollLoad) - if (this.user.followers.length === 0) { - this.fetchFollowers() + if (this.entries.length === 0) { + this.fetchEntries() } }, destroyed () { @@ -23,18 +23,19 @@ const FollowersList = { user () { return this.$store.getters.userById(this.userId) }, - followers () { - return this.user.followers + entries () { + return this.showFollowers ? this.user.followers : this.user.friends } }, methods: { - fetchFollowers () { + fetchEntries () { if (!this.loading) { + const command = this.showFollowers ? 'addFollowers' : 'addFriends' this.loading = true - this.$store.dispatch('addFollowers', this.userId).then(followers => { + this.$store.dispatch(command, this.userId).then(entries => { this.error = false this.loading = false - this.bottomedOut = followers.length === 0 + this.bottomedOut = entries.length === 0 }).catch(() => { this.error = true this.loading = false @@ -49,7 +50,7 @@ const FollowersList = { this.$el.offsetHeight > 0 && (window.innerHeight + window.pageYOffset) >= (height - 750) ) { - this.fetchFollowers() + this.fetchEntries() } } }, @@ -58,4 +59,4 @@ const FollowersList = { } } -export default FollowersList +export default FollowList diff --git a/src/components/follow_list/follow_list.vue b/src/components/follow_list/follow_list.vue new file mode 100644 index 00000000..24ab97d8 --- /dev/null +++ b/src/components/follow_list/follow_list.vue @@ -0,0 +1,33 @@ + + + + + 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 @@ - - -