mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-01-18 19:01:24 +00:00
Improved follow button optimistic behavior
This commit is contained in:
parent
d9b633c5ae
commit
8792f02932
@ -109,6 +109,7 @@
|
||||
:follow-id="author.id"
|
||||
:is-followed="author.followedByCurrentUser"
|
||||
@optimistic="follow => author.followedByCurrentUser = follow"
|
||||
@update="follow => author.followedByCurrentUser = follow"
|
||||
/>
|
||||
</ds-flex-item>
|
||||
<ds-flex-item :width="{base: 1}">
|
||||
|
||||
@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -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()"
|
||||
/>
|
||||
</ds-space>
|
||||
<template v-if="user.about">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user