2018-03-14 16:36:12 +01:00
|
|
|
import { store } from '../_store/store'
|
|
|
|
import { deleteStatus } from '../_api/delete'
|
2018-12-23 00:37:51 +01:00
|
|
|
import { toast } from '../_components/toast/toast'
|
2018-12-13 08:45:52 +01:00
|
|
|
import { deleteStatus as deleteStatusLocally } from './deleteStatuses'
|
2018-03-14 16:36:12 +01:00
|
|
|
|
|
|
|
export async function doDeleteStatus (statusId) {
|
2018-04-19 18:37:05 +02:00
|
|
|
let { currentInstance, accessToken } = store.get()
|
2018-03-14 16:36:12 +01:00
|
|
|
try {
|
2019-07-19 17:09:52 +02:00
|
|
|
let deletedStatus = await deleteStatus(currentInstance, accessToken, statusId)
|
2018-12-13 08:45:52 +01:00
|
|
|
deleteStatusLocally(currentInstance, statusId)
|
2018-03-14 16:36:12 +01:00
|
|
|
toast.say('Status deleted.')
|
2019-07-19 17:09:52 +02:00
|
|
|
return deletedStatus
|
2018-03-14 16:36:12 +01:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e)
|
|
|
|
toast.say('Unable to delete status: ' + (e.message || ''))
|
2019-07-19 17:09:52 +02:00
|
|
|
throw e
|
2018-03-14 16:36:12 +01:00
|
|
|
}
|
|
|
|
}
|