be optimistic about follow button
This commit is contained in:
parent
79e33d7938
commit
48dc087e58
|
@ -28,12 +28,16 @@
|
||||||
async onFollowButtonClick(e) {
|
async onFollowButtonClick(e) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
let account = this.get('account')
|
||||||
let accountId = this.get('accountId')
|
let accountId = this.get('accountId')
|
||||||
let instanceName = this.store.get('currentInstance')
|
|
||||||
let following = this.get('following')
|
let following = this.get('following')
|
||||||
let followRequested = this.get('followRequested')
|
let followRequested = this.get('followRequested')
|
||||||
this.set({animateFollowButton: true})
|
this.set({animateFollowButton: true})
|
||||||
await setAccountFollowed(accountId, !(following || followRequested))
|
let newFollowingValue = !(following || followRequested)
|
||||||
|
await setAccountFollowed(accountId, newFollowingValue)
|
||||||
|
if (!account.locked) { // be optimistic, show the user that it succeeded
|
||||||
|
this.set({overrideFollowing: newFollowingValue)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
store: () => store,
|
store: () => store,
|
||||||
|
@ -42,7 +46,12 @@
|
||||||
}),
|
}),
|
||||||
computed: {
|
computed: {
|
||||||
accountId: (account) => account.id,
|
accountId: (account) => account.id,
|
||||||
following: (relationship) => relationship && relationship.following,
|
following: (relationship, overrideFollowing) => {
|
||||||
|
if (typeof overrideFollowing === 'boolean') {
|
||||||
|
return overrideFollowing
|
||||||
|
}
|
||||||
|
return relationship && relationship.following
|
||||||
|
},
|
||||||
followRequested: (relationship, account) => {
|
followRequested: (relationship, account) => {
|
||||||
return relationship && relationship.requested && account && account.locked
|
return relationship && relationship.requested && account && account.locked
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue