aboutsummaryrefslogtreecommitdiff
path: root/src/components/user_profile/user_profile.js
diff options
context:
space:
mode:
authorshpuld <shp@cock.li>2019-02-02 22:29:10 +0200
committershpuld <shp@cock.li>2019-02-02 22:29:10 +0200
commitdbb16d56e29b8a32fb7c1a7af56a7953f571cdb4 (patch)
treecb7f2e2adc5fe9db8cafb8faa1554cfa81c0c26f /src/components/user_profile/user_profile.js
parent8ce513ed09124fa0183943c359950f49ebcf2f89 (diff)
follows/followers pagination ready for review
Diffstat (limited to 'src/components/user_profile/user_profile.js')
-rw-r--r--src/components/user_profile/user_profile.js76
1 files changed, 23 insertions, 53 deletions
diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js
index 4f09c9e7..0361d253 100644
--- a/src/components/user_profile/user_profile.js
+++ b/src/components/user_profile/user_profile.js
@@ -1,6 +1,8 @@
import UserCardContent from '../user_card_content/user_card_content.vue'
import UserCard from '../user_card/user_card.vue'
import Timeline from '../timeline/timeline.vue'
+import FriendsList from '../friends_list/friends_list.vue'
+import FollowersList from '../followers_list/followers_list.vue'
const UserProfile = {
created () {
@@ -15,15 +17,7 @@ const UserProfile = {
}
},
destroyed () {
- this.$store.dispatch('stopFetching', 'user')
- this.$store.dispatch('stopFetching', 'favorites')
- this.$store.dispatch('stopFetching', 'media')
- },
- data () {
- return {
- followsPage: 0,
- followersPage: 0
- }
+ this.cleanUp(this.userId)
},
computed: {
timeline () {
@@ -45,12 +39,6 @@ const UserProfile = {
return this.userId && this.$store.state.users.currentUser.id &&
this.userId === this.$store.state.users.currentUser.id
},
- friends () {
- return this.user.friends
- },
- followers () {
- return this.user.followers
- },
userInStore () {
if (this.isExternal) {
return this.$store.getters.userById(this.userId)
@@ -74,66 +62,48 @@ const UserProfile = {
}
},
methods: {
- fetchFollowers () {
- const id = this.userId
- this.$store.dispatch('addFollowers', { id })
- },
- fetchFriends () {
- const id = this.userId
- this.$store.dispatch('addFriends', { id })
- },
startFetchFavorites () {
if (this.isUs) {
this.$store.dispatch('startFetching', ['favorites', this.fetchBy])
}
},
- nextFollowsPage () {
- this.followsPage += 1
- this.$store.dispatch('addFriends', { id: this.userId, page: this.followsPage })
- console.log(this.user.friends)
- }
- },
- watch: {
- // TODO get rid of this copypasta
- userName () {
- if (this.isExternal) {
- return
- }
- this.$store.dispatch('stopFetching', 'user')
- this.$store.dispatch('stopFetching', 'favorites')
- this.$store.dispatch('stopFetching', 'media')
- this.$store.commit('clearTimeline', { timeline: 'user' })
- this.$store.commit('clearTimeline', { timeline: 'favorites' })
- this.$store.commit('clearTimeline', { timeline: 'media' })
+ startUp () {
this.$store.dispatch('startFetching', ['user', this.fetchBy])
this.$store.dispatch('startFetching', ['media', this.fetchBy])
+
this.startFetchFavorites()
},
- userId () {
- if (!this.isExternal) {
- return
- }
+ cleanUp () {
this.$store.dispatch('stopFetching', 'user')
this.$store.dispatch('stopFetching', 'favorites')
this.$store.dispatch('stopFetching', 'media')
this.$store.commit('clearTimeline', { timeline: 'user' })
this.$store.commit('clearTimeline', { timeline: 'favorites' })
this.$store.commit('clearTimeline', { timeline: 'media' })
- this.$store.dispatch('startFetching', ['user', this.fetchBy])
- this.$store.dispatch('startFetching', ['media', this.fetchBy])
- this.startFetchFavorites()
+ }
+ },
+ watch: {
+ userName () {
+ if (this.isExternal) {
+ return
+ }
+ this.cleanUp()
+ this.startUp()
},
- user () {
- if (this.user.id && !this.user.followers) {
- this.fetchFollowers()
- this.fetchFriends()
+ userId () {
+ if (!this.isExternal) {
+ return
}
+ this.cleanUp()
+ this.startUp()
}
},
components: {
UserCardContent,
UserCard,
- Timeline
+ Timeline,
+ FriendsList,
+ FollowersList
}
}