From ccfc2e57d0e265bddc88d5ace30428268f3b1df1 Mon Sep 17 00:00:00 2001 From: eal Date: Mon, 21 Aug 2017 20:25:01 +0300 Subject: Add follower and following views --- src/components/timeline/timeline.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'src/components/timeline/timeline.js') diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index 3dc07f9e..7a590865 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -1,20 +1,32 @@ import Status from '../status/status.vue' import timelineFetcher from '../../services/timeline_fetcher/timeline_fetcher.service.js' import StatusOrConversation from '../status_or_conversation/status_or_conversation.vue' +import UserCard from '../user_card/user_card.vue' const Timeline = { props: [ 'timeline', 'timelineName', 'title', + 'showingStatuses', 'userId' ], computed: { - timelineError () { return this.$store.state.statuses.error } + timelineError () { return this.$store.state.statuses.error }, + followers () { + return this.timeline.followers + }, + friends () { + return this.timeline.friends + }, + viewing () { + return this.timeline.viewing + } }, components: { Status, - StatusOrConversation + StatusOrConversation, + UserCard }, created () { const store = this.$store @@ -30,6 +42,12 @@ const Timeline = { showImmediately, userId: this.userId }) + + // don't fetch followers for public, friend, twkn + if (this.timelineName === 'user') { + this.fetchFriends() + this.fetchFollowers() + } }, methods: { showNewStatuses () { @@ -48,6 +66,16 @@ const Timeline = { userId: this.userId }).then(() => store.commit('setLoading', { timeline: this.timelineName, value: false })) }, + fetchFollowers() { + const id = this.userId + this.$store.state.api.backendInteractor.fetchFollowers({ id }) + .then((followers) => this.$store.dispatch('addFollowers', { followers })) + }, + fetchFriends() { + const id = this.userId + this.$store.state.api.backendInteractor.fetchFriends({ id }) + .then((friends) => this.$store.dispatch('addFriends', { friends })) + }, scrollLoad (e) { let height = Math.max(document.body.offsetHeight, document.body.scrollHeight) if (this.timeline.loading === false && this.$store.state.config.autoLoad && (window.innerHeight + window.pageYOffset) >= (height - 750)) { -- cgit v1.2.3-70-g09d2 From e1ec01dc3ef90c0dc033d2e648da9a2acf8a1bdd Mon Sep 17 00:00:00 2001 From: eal Date: Wed, 23 Aug 2017 19:21:15 +0300 Subject: Appease linter. --- src/components/timeline/timeline.js | 5 ++--- src/components/user_profile/user_profile.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/components/timeline/timeline.js') diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index 7a590865..06435745 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -8,7 +8,6 @@ const Timeline = { 'timeline', 'timelineName', 'title', - 'showingStatuses', 'userId' ], computed: { @@ -66,12 +65,12 @@ const Timeline = { userId: this.userId }).then(() => store.commit('setLoading', { timeline: this.timelineName, value: false })) }, - fetchFollowers() { + fetchFollowers () { const id = this.userId this.$store.state.api.backendInteractor.fetchFollowers({ id }) .then((followers) => this.$store.dispatch('addFollowers', { followers })) }, - fetchFriends() { + fetchFriends () { const id = this.userId this.$store.state.api.backendInteractor.fetchFriends({ id }) .then((friends) => this.$store.dispatch('addFriends', { friends })) diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 1ce6e5f2..5f9d4d08 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -20,11 +20,11 @@ const UserProfile = { } else { return false } - }, + } }, components: { UserCardContent, - Timeline, + Timeline } } -- cgit v1.2.3-70-g09d2