From fb8f774383f122d3254748f7f97ab6c562a5c339 Mon Sep 17 00:00:00 2001 From: Shpuld Shpludson Date: Mon, 31 Dec 2018 01:57:22 +0000 Subject: Fix profiles without statuses not loading --- src/components/user_profile/user_profile.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 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 77bb1835..2ca09817 100644 --- a/src/components/user_profile/user_profile.js +++ b/src/components/user_profile/user_profile.js @@ -6,7 +6,7 @@ const UserProfile = { created () { this.$store.commit('clearTimeline', { timeline: 'user' }) this.$store.dispatch('startFetching', ['user', this.fetchBy]) - if (!this.user) { + if (!this.user.id) { this.$store.dispatch('fetchUser', this.fetchBy) } }, @@ -29,14 +29,20 @@ const UserProfile = { followers () { return this.user.followers }, + userInStore () { + if (this.isExternal) { + return this.$store.getters.userById(this.userId) + } + return this.$store.getters.userByName(this.userName) + }, user () { if (this.timeline.statuses[0]) { return this.timeline.statuses[0].user - } else { - return Object.values(this.$store.state.users.usersObject).filter(user => { - return (this.isExternal ? user.id === this.userId : user.screen_name === this.userName) - })[0] || {} } + if (this.userInStore) { + return this.userInStore + } + return {} }, fetchBy () { return this.isExternal ? this.userId : this.userName -- cgit v1.2.3-70-g09d2