aboutsummaryrefslogtreecommitdiff
path: root/src/services/follow_manipulate/follow_manipulate.js
diff options
context:
space:
mode:
authorShpuld Shpludson <shp@cock.li>2020-05-12 17:36:05 +0000
committerShpuld Shpludson <shp@cock.li>2020-05-12 17:36:05 +0000
commit5d49edc823ba2ea3e34d4fd6c5efcc84ef9712f7 (patch)
treef4a7a9c10d00083b36fb331c1d9196dc391dcfc7 /src/services/follow_manipulate/follow_manipulate.js
parenta0f780c4550b77d4574e0de8932a2dff288784a3 (diff)
parent0bc0a8d5f51f88858a7347b915361c45ff819292 (diff)
Merge branch 'rc/2.0.5' into 'master'
Update MASTER for 2.0.5 patch See merge request pleroma/pleroma-fe!1105
Diffstat (limited to 'src/services/follow_manipulate/follow_manipulate.js')
-rw-r--r--src/services/follow_manipulate/follow_manipulate.js25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/services/follow_manipulate/follow_manipulate.js b/src/services/follow_manipulate/follow_manipulate.js
index 29b38a0f..08f4c4d6 100644
--- a/src/services/follow_manipulate/follow_manipulate.js
+++ b/src/services/follow_manipulate/follow_manipulate.js
@@ -1,24 +1,27 @@
-const fetchUser = (attempt, user, store) => new Promise((resolve, reject) => {
+const fetchRelationship = (attempt, userId, store) => new Promise((resolve, reject) => {
setTimeout(() => {
- store.state.api.backendInteractor.fetchUser({ id: user.id })
- .then((user) => store.commit('addNewUsers', [user]))
- .then(() => resolve([user.following, user.requested, user.locked, attempt]))
+ store.state.api.backendInteractor.fetchUserRelationship({ id: userId })
+ .then((relationship) => {
+ store.commit('updateUserRelationship', [relationship])
+ return relationship
+ })
+ .then((relationship) => resolve([relationship.following, relationship.requested, relationship.locked, attempt]))
.catch((e) => reject(e))
}, 500)
}).then(([following, sent, locked, attempt]) => {
if (!following && !(locked && sent) && attempt <= 3) {
// If we BE reports that we still not following that user - retry,
// increment attempts by one
- fetchUser(++attempt, user, store)
+ fetchRelationship(++attempt, userId, store)
}
})
-export const requestFollow = (user, store) => new Promise((resolve, reject) => {
- store.state.api.backendInteractor.followUser({ id: user.id })
+export const requestFollow = (userId, store) => new Promise((resolve, reject) => {
+ store.state.api.backendInteractor.followUser({ id: userId })
.then((updated) => {
store.commit('updateUserRelationship', [updated])
- if (updated.following || (user.locked && user.requested)) {
+ if (updated.following || (updated.locked && updated.requested)) {
// If we get result immediately or the account is locked, just stop.
resolve()
return
@@ -31,15 +34,15 @@ export const requestFollow = (user, store) => new Promise((resolve, reject) => {
// don't know that yet.
// Recursive Promise, it will call itself up to 3 times.
- return fetchUser(1, user, store)
+ return fetchRelationship(1, updated, store)
.then(() => {
resolve()
})
})
})
-export const requestUnfollow = (user, store) => new Promise((resolve, reject) => {
- store.state.api.backendInteractor.unfollowUser({ id: user.id })
+export const requestUnfollow = (userId, store) => new Promise((resolve, reject) => {
+ store.state.api.backendInteractor.unfollowUser({ id: userId })
.then((updated) => {
store.commit('updateUserRelationship', [updated])
resolve({