From 090148ef6051ec2399fe47281db9f73955297d97 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 12 Jun 2017 16:00:46 +0200 Subject: Start fetching user timelines. --- src/components/user_profile/user_profile.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/components/user_profile/user_profile.js') diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 4d52bc95..4f35cf27 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -1,12 +1,18 @@ import UserCardContent from '../user_card_content/user_card_content.vue' -import { find } from 'lodash' const UserProfile = { + created () { + this.$store.dispatch('startFetching', ['user', this.userId]) + }, + destroyed () { + this.$store.dispatch('stopFetching', ['user', this.userId]) + }, computed: { + userId () { + return this.$route.params.id + }, user () { - const id = this.$route.params.id - const user = find(this.$store.state.users.users, {id}) - return user + return this.$store.state.users.usersObject[this.userId] } }, components: { -- cgit v1.2.3-70-g09d2 From 2e7029b67027dae7ee3202553c0c9e288c882730 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 12 Jun 2017 16:20:02 +0200 Subject: Display user timeline --- src/components/user_profile/user_profile.js | 7 +++++-- src/components/user_profile/user_profile.vue | 7 +++++-- src/services/api/api.service.js | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/components/user_profile/user_profile.js') diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 4f35cf27..5eef2735 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -1,13 +1,15 @@ import UserCardContent from '../user_card_content/user_card_content.vue' +import Timeline from '../timeline/timeline.vue' const UserProfile = { created () { this.$store.dispatch('startFetching', ['user', this.userId]) }, destroyed () { - this.$store.dispatch('stopFetching', ['user', this.userId]) + this.$store.dispatch('stopFetching', 'user') }, computed: { + timeline () { return this.$store.state.statuses.timelines.user }, userId () { return this.$route.params.id }, @@ -16,7 +18,8 @@ const UserProfile = { } }, components: { - UserCardContent + UserCardContent, + Timeline } } diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue index fe693c9d..0765b01c 100644 --- a/src/components/user_profile/user_profile.vue +++ b/src/components/user_profile/user_profile.vue @@ -1,6 +1,9 @@ diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 3715a211..026dae73 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -113,11 +113,11 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, use let params = [] if (since) { - params.push('since_id', since) + params.push(['since_id', since]) } if (until) { - params.push('max_id', until) + params.push(['max_id', until]) } if (userId) { -- cgit v1.2.3-70-g09d2 From bda0a76c89cadc6251261a08575acf6986da1084 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 12 Jun 2017 16:30:56 +0200 Subject: Clear timeline on user change. --- src/components/user_profile/user_profile.js | 1 + src/modules/statuses.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) (limited to 'src/components/user_profile/user_profile.js') diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 5eef2735..3d473592 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -3,6 +3,7 @@ import Timeline from '../timeline/timeline.vue' const UserProfile = { created () { + this.$store.commit('clearTimeline', { timeline: 'user' }) this.$store.dispatch('startFetching', ['user', this.userId]) }, destroyed () { diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 372567c5..0b4069c6 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -295,6 +295,21 @@ export const mutations = { oldTimeline.visibleStatusesObject = {} each(oldTimeline.visibleStatuses, (status) => { oldTimeline.visibleStatusesObject[status.id] = status }) }, + clearTimeline (state, { timeline }) { + const emptyTimeline = { + statuses: [], + statusesObject: {}, + faves: [], + visibleStatuses: [], + visibleStatusesObject: {}, + newStatusCount: 0, + maxId: 0, + minVisibleId: 0, + loading: false + } + + state.timelines[timeline] = emptyTimeline + }, setFavorited (state, { status, value }) { const newStatus = state.allStatusesObject[status.id] newStatus.favorited = value -- cgit v1.2.3-70-g09d2 From bbb9a9c93c4ca195eb19fe4dc73ef95968738125 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Mon, 12 Jun 2017 17:07:10 +0200 Subject: Fetch user from timeline. --- src/components/user_profile/user_profile.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/components/user_profile/user_profile.js') diff --git a/src/components/user_profile/user_profile.js b/src/components/user_profile/user_profile.js index 3d473592..5f9d4d08 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -15,7 +15,11 @@ const UserProfile = { return this.$route.params.id }, user () { - return this.$store.state.users.usersObject[this.userId] + if (this.timeline.statuses[0]) { + return this.timeline.statuses[0].user + } else { + return false + } } }, components: { -- cgit v1.2.3-70-g09d2