fix incorrect toast notification for follow requests (#493)
This commit is contained in:
parent
4a0cfb8d6e
commit
8959cdaeb1
|
@ -2,28 +2,19 @@ import { store } from '../_store/store'
|
||||||
import { followAccount, unfollowAccount } from '../_api/follow'
|
import { followAccount, unfollowAccount } from '../_api/follow'
|
||||||
import { toast } from '../_utils/toast'
|
import { toast } from '../_utils/toast'
|
||||||
import { updateProfileAndRelationship } from './accounts'
|
import { updateProfileAndRelationship } from './accounts'
|
||||||
import {
|
|
||||||
getRelationship as getRelationshipFromDatabase
|
|
||||||
} from '../_database/relationships'
|
|
||||||
|
|
||||||
export async function setAccountFollowed (accountId, follow, toastOnSuccess) {
|
export async function setAccountFollowed (accountId, follow, toastOnSuccess) {
|
||||||
let { currentInstance, accessToken } = store.get()
|
let { currentInstance, accessToken } = store.get()
|
||||||
try {
|
try {
|
||||||
let account
|
|
||||||
if (follow) {
|
if (follow) {
|
||||||
account = await followAccount(currentInstance, accessToken, accountId)
|
await followAccount(currentInstance, accessToken, accountId)
|
||||||
} else {
|
} else {
|
||||||
account = await unfollowAccount(currentInstance, accessToken, accountId)
|
await unfollowAccount(currentInstance, accessToken, accountId)
|
||||||
}
|
}
|
||||||
await updateProfileAndRelationship(accountId)
|
await updateProfileAndRelationship(accountId)
|
||||||
let relationship = await getRelationshipFromDatabase(currentInstance, accountId)
|
|
||||||
if (toastOnSuccess) {
|
if (toastOnSuccess) {
|
||||||
if (follow) {
|
if (follow) {
|
||||||
if (account.locked && relationship.requested) {
|
toast.say('Followed account')
|
||||||
toast.say('Requested to follow account')
|
|
||||||
} else {
|
|
||||||
toast.say('Followed account')
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
toast.say('Unfollowed account')
|
toast.say('Unfollowed account')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue