diff --git a/components/Author.vue b/components/Author.vue index f12e53d3e..773037fac 100644 --- a/components/Author.vue +++ b/components/Author.vue @@ -109,6 +109,7 @@ :follow-id="author.id" :is-followed="author.followedByCurrentUser" @optimistic="follow => author.followedByCurrentUser = follow" + @update="follow => author.followedByCurrentUser = follow" /> diff --git a/components/FollowButton.vue b/components/FollowButton.vue index 7cce2e65a..676aa1a83 100644 --- a/components/FollowButton.vue +++ b/components/FollowButton.vue @@ -79,14 +79,11 @@ export default { } }) .then(res => { - if (res && res.data) { - this.$emit('update', follow) - } else { - this.$emit('optimistic', this.isFollowed) - } + this.$emit('update', follow ? res.data.follow : follow) + this.$emit('optimistic', follow ? res.data.follow : follow) }) .catch(() => { - this.$emit('optimistic', this.isFollowed) + this.$emit('optimistic', !follow) }) } } diff --git a/pages/profile/_slug.vue b/pages/profile/_slug.vue index 5880921c0..f83e25e1f 100644 --- a/pages/profile/_slug.vue +++ b/pages/profile/_slug.vue @@ -88,7 +88,7 @@ :follow-id="user.id" :is-followed="user.followedByCurrentUser" @optimistic="follow => user.followedByCurrentUser = follow" - @update="follow => fetchUser()" + @update="follow => user.followedByCurrentUser = follow && fetchUser()" />