4bd181d3cc
* fix: update to latest sapper fixes #416 * fix error and debug pages * requestIdleCallback makes column switching feel way nicer than double rAF * add export feature * add better csp info * workaround for sapper sub-page issue * clarify in readme about exporting * fix now config * switch from rIC to triple raf * style-loader is no longer used * update theming guide
27 lines
821 B
JavaScript
27 lines
821 B
JavaScript
import { store } from '../_store/store'
|
|
import { blockDomain, unblockDomain } from '../_api/blockDomain'
|
|
import { toast } from '../_utils/toast'
|
|
import { updateRelationship } from './accounts'
|
|
|
|
export async function setDomainBlocked (accountId, domain, block, toastOnSuccess) {
|
|
let { currentInstance, accessToken } = store.get()
|
|
try {
|
|
if (block) {
|
|
await blockDomain(currentInstance, accessToken, domain)
|
|
} else {
|
|
await unblockDomain(currentInstance, accessToken, domain)
|
|
}
|
|
await updateRelationship(accountId)
|
|
if (toastOnSuccess) {
|
|
if (block) {
|
|
toast.say(`Hiding ${domain}`)
|
|
} else {
|
|
toast.say(`Unhiding ${domain}`)
|
|
}
|
|
}
|
|
} catch (e) {
|
|
console.error(e)
|
|
toast.say(`Unable to ${block ? 'hide' : 'unhide'} domain: ` + (e.message || ''))
|
|
}
|
|
}
|