2021-07-05 03:19:04 +00:00
|
|
|
import { store } from '../_store/store.js'
|
|
|
|
import { deleteStatus } from '../_api/delete.js'
|
|
|
|
import { toast } from '../_components/toast/toast.js'
|
|
|
|
import { deleteStatus as deleteStatusLocally } from './deleteStatuses.js'
|
|
|
|
import { formatIntl } from '../_utils/formatIntl.js'
|
2018-03-14 15:36:12 +00:00
|
|
|
|
|
|
|
export async function doDeleteStatus (statusId) {
|
2019-08-03 20:49:37 +00:00
|
|
|
const { currentInstance, accessToken } = store.get()
|
2018-03-14 15:36:12 +00:00
|
|
|
try {
|
2019-08-03 20:49:37 +00:00
|
|
|
const deletedStatus = await deleteStatus(currentInstance, accessToken, statusId)
|
2018-12-13 07:45:52 +00:00
|
|
|
deleteStatusLocally(currentInstance, statusId)
|
2020-11-29 22:13:27 +00:00
|
|
|
/* no await */ toast.say('intl.statusDeleted')
|
2019-07-19 15:09:52 +00:00
|
|
|
return deletedStatus
|
2018-03-14 15:36:12 +00:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
2020-11-29 22:13:27 +00:00
|
|
|
/* no await */ toast.say(formatIntl('intl.unableToDelete', { error: (e.message || '') }))
|
2019-07-19 15:09:52 +00:00
|
|
|
throw e
|
2018-03-14 15:36:12 +00:00
|
|
|
}
|
|
|
|
}
|