* first attempt * progress * working * working * test timeago * rm * get timeago working * reduce size * fix whitespace * more intl stuff * more effort * more work * more progress * more work * more intl * set lang=LOCALE * flatten * more work * add ltr/rtl * more work * add comments * yet more work * still more work * more work * fix tests * more test and string fixes * fix test * fix test * fix test * fix some more strings, add test * fix snackbar * fix } * fix typo * fix english * measure perf * start on french * more work on french * more french * more french * finish french * fix some missing translations * update readme * fix test
27 lines
952 B
JavaScript
27 lines
952 B
JavaScript
import { store } from '../_store/store'
|
|
import { blockDomain, unblockDomain } from '../_api/blockDomain'
|
|
import { toast } from '../_components/toast/toast'
|
|
import { updateRelationship } from './accounts'
|
|
import { formatIntl } from '../_utils/formatIntl'
|
|
|
|
export async function setDomainBlocked (accountId, domain, block, toastOnSuccess) {
|
|
const { currentInstance, accessToken } = store.get()
|
|
try {
|
|
if (block) {
|
|
await blockDomain(currentInstance, accessToken, domain)
|
|
} else {
|
|
await unblockDomain(currentInstance, accessToken, domain)
|
|
}
|
|
await updateRelationship(accountId)
|
|
if (toastOnSuccess) {
|
|
/* no await */ toast.say(block ? 'intl.hidDomain' : 'intl.unhidDomain')
|
|
}
|
|
} catch (e) {
|
|
console.error(e)
|
|
/* no await */ toast.say(block
|
|
? formatIntl('intl.unableToHideDomain', { error: (e.message || '') })
|
|
: formatIntl('intl.unableToUnhideDomain', { error: (e.message || '') })
|
|
)
|
|
}
|
|
}
|