Merge branch 'fix/follow-request-detection' into 'develop'
Utilize `user.requested` to display follow request status on user card Closes #635 See merge request pleroma/pleroma-fe!942
This commit is contained in:
commit
4a469d7fe3
3 changed files with 7 additions and 12 deletions
|
@ -11,7 +11,6 @@ export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
followRequestInProgress: false,
|
followRequestInProgress: false,
|
||||||
followRequestSent: false,
|
|
||||||
hideUserStatsLocal: typeof this.$store.state.config.hideUserStats === 'undefined'
|
hideUserStatsLocal: typeof this.$store.state.config.hideUserStats === 'undefined'
|
||||||
? this.$store.state.instance.hideUserStats
|
? this.$store.state.instance.hideUserStats
|
||||||
: this.$store.state.config.hideUserStats,
|
: this.$store.state.config.hideUserStats,
|
||||||
|
@ -112,9 +111,8 @@ export default {
|
||||||
followUser () {
|
followUser () {
|
||||||
const store = this.$store
|
const store = this.$store
|
||||||
this.followRequestInProgress = true
|
this.followRequestInProgress = true
|
||||||
requestFollow(this.user, store).then(({ sent }) => {
|
requestFollow(this.user, store).then(() => {
|
||||||
this.followRequestInProgress = false
|
this.followRequestInProgress = false
|
||||||
this.followRequestSent = sent
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
unfollowUser () {
|
unfollowUser () {
|
||||||
|
|
|
@ -135,13 +135,13 @@
|
||||||
<button
|
<button
|
||||||
class="btn btn-default btn-block"
|
class="btn btn-default btn-block"
|
||||||
:disabled="followRequestInProgress"
|
:disabled="followRequestInProgress"
|
||||||
:title="followRequestSent ? $t('user_card.follow_again') : ''"
|
:title="user.requested ? $t('user_card.follow_again') : ''"
|
||||||
@click="followUser"
|
@click="followUser"
|
||||||
>
|
>
|
||||||
<template v-if="followRequestInProgress">
|
<template v-if="followRequestInProgress">
|
||||||
{{ $t('user_card.follow_progress') }}
|
{{ $t('user_card.follow_progress') }}
|
||||||
</template>
|
</template>
|
||||||
<template v-else-if="followRequestSent">
|
<template v-else-if="user.requested">
|
||||||
{{ $t('user_card.follow_sent') }}
|
{{ $t('user_card.follow_sent') }}
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
|
|
|
@ -9,10 +9,7 @@ const fetchUser = (attempt, user, store) => new Promise((resolve, reject) => {
|
||||||
if (!following && !(locked && sent) && attempt <= 3) {
|
if (!following && !(locked && sent) && attempt <= 3) {
|
||||||
// If we BE reports that we still not following that user - retry,
|
// If we BE reports that we still not following that user - retry,
|
||||||
// increment attempts by one
|
// increment attempts by one
|
||||||
return fetchUser(++attempt, user, store)
|
fetchUser(++attempt, user, store)
|
||||||
} else {
|
|
||||||
// If we run out of attempts, just return whatever status is.
|
|
||||||
return sent
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -23,7 +20,7 @@ export const requestFollow = (user, store) => new Promise((resolve, reject) => {
|
||||||
|
|
||||||
if (updated.following || (user.locked && user.requested)) {
|
if (updated.following || (user.locked && user.requested)) {
|
||||||
// If we get result immediately or the account is locked, just stop.
|
// If we get result immediately or the account is locked, just stop.
|
||||||
resolve({ sent: updated.requested })
|
resolve()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,8 +32,8 @@ export const requestFollow = (user, store) => new Promise((resolve, reject) => {
|
||||||
// Recursive Promise, it will call itself up to 3 times.
|
// Recursive Promise, it will call itself up to 3 times.
|
||||||
|
|
||||||
return fetchUser(1, user, store)
|
return fetchUser(1, user, store)
|
||||||
.then((sent) => {
|
.then(() => {
|
||||||
resolve({ sent })
|
resolve()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue