2018-08-26 05:03:33 +00:00
|
|
|
import { store } from '../_store/store'
|
|
|
|
import { setShowReblogs as setShowReblogsApi } from '../_api/showReblogs'
|
|
|
|
import { toast } from '../_utils/toast'
|
2018-08-26 19:14:08 +00:00
|
|
|
import { updateLocalRelationship } from './accounts'
|
2018-08-26 05:03:33 +00:00
|
|
|
|
|
|
|
export async function setShowReblogs (accountId, showReblogs, toastOnSuccess) {
|
|
|
|
let { currentInstance, accessToken } = store.get()
|
|
|
|
try {
|
2018-08-26 19:14:08 +00:00
|
|
|
let relationship = await setShowReblogsApi(currentInstance, accessToken, accountId, showReblogs)
|
|
|
|
await updateLocalRelationship(currentInstance, accountId, relationship)
|
2018-08-26 05:03:33 +00:00
|
|
|
if (toastOnSuccess) {
|
|
|
|
if (showReblogs) {
|
|
|
|
toast.say('Showing boosts')
|
|
|
|
} else {
|
|
|
|
toast.say('Hiding boosts')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
toast.say(`Unable to ${showReblogs ? 'show' : 'hide'} boosts: ` + (e.message || ''))
|
|
|
|
}
|
|
|
|
}
|