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