2018-08-26 05:03:33 +00:00
|
|
|
import { store } from '../_store/store'
|
|
|
|
import { setShowReblogs as setShowReblogsApi } from '../_api/showReblogs'
|
2018-12-22 23:37:51 +00:00
|
|
|
import { toast } from '../_components/toast/toast'
|
2018-08-26 19:14:08 +00:00
|
|
|
import { updateLocalRelationship } from './accounts'
|
2020-11-29 22:13:27 +00:00
|
|
|
import { formatIntl } from '../_utils/formatIntl'
|
2018-08-26 05:03:33 +00:00
|
|
|
|
|
|
|
export async function setShowReblogs (accountId, showReblogs, toastOnSuccess) {
|
2019-08-03 20:49:37 +00:00
|
|
|
const { currentInstance, accessToken } = store.get()
|
2018-08-26 05:03:33 +00:00
|
|
|
try {
|
2019-08-03 20:49:37 +00:00
|
|
|
const relationship = await setShowReblogsApi(currentInstance, accessToken, accountId, showReblogs)
|
2018-08-26 19:14:08 +00:00
|
|
|
await updateLocalRelationship(currentInstance, accountId, relationship)
|
2018-08-26 05:03:33 +00:00
|
|
|
if (toastOnSuccess) {
|
2020-11-29 22:13:27 +00:00
|
|
|
/* no await */ toast.say(showReblogs ? 'intl.showingReblogs' : 'intl.hidingReblogs')
|
2018-08-26 05:03:33 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
2020-11-29 22:13:27 +00:00
|
|
|
/* no await */ toast.say(showReblogs
|
|
|
|
? formatIntl('intl.unableToShowReblogs', { error: (e.message || '') })
|
|
|
|
: formatIntl('intl.unableToHideReblogs', { error: (e.message || '') })
|
|
|
|
)
|
2018-08-26 05:03:33 +00:00
|
|
|
}
|
|
|
|
}
|