Merge branch 'fix/incorrect-follow-request-status' into 'develop'
Fix sent follow request detection See merge request pleroma/pleroma-fe!910
This commit is contained in:
commit
7e2d48a26e
|
@ -65,6 +65,7 @@ export const parseUser = (data) => {
|
|||
|
||||
if (relationship) {
|
||||
output.follows_you = relationship.followed_by
|
||||
output.requested = relationship.requested
|
||||
output.following = relationship.following
|
||||
output.statusnet_blocking = relationship.blocking
|
||||
output.muted = relationship.muting
|
||||
|
|
|
@ -2,17 +2,17 @@ const fetchUser = (attempt, user, store) => new Promise((resolve, reject) => {
|
|||
setTimeout(() => {
|
||||
store.state.api.backendInteractor.fetchUser({ id: user.id })
|
||||
.then((user) => store.commit('addNewUsers', [user]))
|
||||
.then(() => resolve([user.following, attempt]))
|
||||
.then(() => resolve([user.following, user.requested, user.locked, attempt]))
|
||||
.catch((e) => reject(e))
|
||||
}, 500)
|
||||
}).then(([following, attempt]) => {
|
||||
if (!following && attempt <= 3) {
|
||||
}).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
|
||||
return fetchUser(++attempt, user, store)
|
||||
} else {
|
||||
// If we run out of attempts, just return whatever status is.
|
||||
return following
|
||||
return sent
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -21,14 +21,10 @@ export const requestFollow = (user, store) => new Promise((resolve, reject) => {
|
|||
.then((updated) => {
|
||||
store.commit('updateUserRelationship', [updated])
|
||||
|
||||
// For locked users we just mark it that we sent the follow request
|
||||
if (updated.locked) {
|
||||
resolve({ sent: true })
|
||||
}
|
||||
|
||||
if (updated.following) {
|
||||
// If we get result immediately, just stop.
|
||||
resolve({ sent: false })
|
||||
if (updated.following || (user.locked && user.requested)) {
|
||||
// If we get result immediately or the account is locked, just stop.
|
||||
resolve({ sent: updated.requested })
|
||||
return
|
||||
}
|
||||
|
||||
// But usually we don't get result immediately, so we ask server
|
||||
|
@ -39,14 +35,8 @@ export const requestFollow = (user, store) => new Promise((resolve, reject) => {
|
|||
// Recursive Promise, it will call itself up to 3 times.
|
||||
|
||||
return fetchUser(1, user, store)
|
||||
.then((following) => {
|
||||
if (following) {
|
||||
// We confirmed and everything's good.
|
||||
resolve({ sent: false })
|
||||
} else {
|
||||
// If after all the tries, just treat it as if user is locked
|
||||
resolve({ sent: false })
|
||||
}
|
||||
.then((sent) => {
|
||||
resolve({ sent })
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue