pinafore/src/routes/_actions/delete.js
2019-08-03 13:49:37 -07:00

19 lines
634 B
JavaScript

import { store } from '../_store/store'
import { deleteStatus } from '../_api/delete'
import { toast } from '../_components/toast/toast'
import { deleteStatus as deleteStatusLocally } from './deleteStatuses'
export async function doDeleteStatus (statusId) {
const { currentInstance, accessToken } = store.get()
try {
const deletedStatus = await deleteStatus(currentInstance, accessToken, statusId)
deleteStatusLocally(currentInstance, statusId)
toast.say('Status deleted.')
return deletedStatus
} catch (e) {
console.error(e)
toast.say('Unable to delete status: ' + (e.message || ''))
throw e
}
}