2018-04-15 07:18:48 +02:00
|
|
|
import { store } from '../_store/store'
|
|
|
|
import { muteAccount, unmuteAccount } from '../_api/mute'
|
|
|
|
import { toast } from '../_utils/toast'
|
|
|
|
import { updateProfileAndRelationship } from './accounts'
|
|
|
|
|
|
|
|
export async function setAccountMuted (accountId, mute, toastOnSuccess) {
|
2018-04-19 18:37:05 +02:00
|
|
|
let { currentInstance, accessToken } = store.get()
|
2018-04-15 07:18:48 +02:00
|
|
|
try {
|
|
|
|
if (mute) {
|
2018-04-19 18:37:05 +02:00
|
|
|
await muteAccount(currentInstance, accessToken, accountId)
|
2018-04-15 07:18:48 +02:00
|
|
|
} else {
|
2018-04-19 18:37:05 +02:00
|
|
|
await unmuteAccount(currentInstance, accessToken, accountId)
|
2018-04-15 07:18:48 +02:00
|
|
|
}
|
|
|
|
await updateProfileAndRelationship(accountId)
|
|
|
|
if (toastOnSuccess) {
|
|
|
|
if (mute) {
|
|
|
|
toast.say('Muted account')
|
|
|
|
} else {
|
|
|
|
toast.say('Unmuted account')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
toast.say(`Unable to ${mute ? 'mute' : 'unmute'} account: ` + (e.message || ''))
|
|
|
|
}
|
|
|
|
}
|