mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Make follow button update instant
This commit is contained in:
parent
d30649164a
commit
d9b633c5ae
@ -108,7 +108,7 @@
|
||||
<hc-follow-button
|
||||
:follow-id="author.id"
|
||||
:is-followed="author.followedByCurrentUser"
|
||||
@update="following => author.followedByCurrentUser = following"
|
||||
@optimistic="follow => author.followedByCurrentUser = follow"
|
||||
/>
|
||||
</ds-flex-item>
|
||||
<ds-flex-item :width="{base: 1}">
|
||||
|
||||
@ -64,6 +64,9 @@ export default {
|
||||
const mutation = follow ? 'follow' : 'unfollow'
|
||||
|
||||
this.hovered = false
|
||||
|
||||
this.$emit('optimistic', follow)
|
||||
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: gql`
|
||||
@ -78,8 +81,13 @@ export default {
|
||||
.then(res => {
|
||||
if (res && res.data) {
|
||||
this.$emit('update', follow)
|
||||
} else {
|
||||
this.$emit('optimistic', this.isFollowed)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.$emit('optimistic', this.isFollowed)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ export default {
|
||||
})
|
||||
.then(res => {
|
||||
if (res && res.data) {
|
||||
this.$emit('update')
|
||||
this.$emit('update', shout)
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
|
||||
@ -87,7 +87,8 @@
|
||||
v-if="!myProfile"
|
||||
:follow-id="user.id"
|
||||
:is-followed="user.followedByCurrentUser"
|
||||
@update="voted = true && fetchUser()"
|
||||
@optimistic="follow => user.followedByCurrentUser = follow"
|
||||
@update="follow => fetchUser()"
|
||||
/>
|
||||
</ds-space>
|
||||
<template v-if="user.about">
|
||||
@ -336,10 +337,6 @@ export default {
|
||||
},
|
||||
followedByCount() {
|
||||
let count = Number(this.user.followedByCount) || 0
|
||||
if (this.voted) {
|
||||
// NOTE: this is used for presentation
|
||||
count += 1
|
||||
}
|
||||
return count
|
||||
},
|
||||
user() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user