Pinafore-Web-Client-Frontend/src/routes/_actions/delete.js

19 lines
634 B
JavaScript
Raw Normal View History

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'
import { deleteStatus as deleteStatusLocally } from './deleteStatuses'
2018-03-14 16:36:12 +01:00
export async function doDeleteStatus (statusId) {
2019-08-03 22:49:37 +02:00
const { currentInstance, accessToken } = store.get()
2018-03-14 16:36:12 +01:00
try {
2019-08-03 22:49:37 +02:00
const deletedStatus = await deleteStatus(currentInstance, accessToken, statusId)
deleteStatusLocally(currentInstance, statusId)
2018-03-14 16:36:12 +01:00
toast.say('Status deleted.')
return deletedStatus
2018-03-14 16:36:12 +01:00
} catch (e) {
console.error(e)
toast.say('Unable to delete status: ' + (e.message || ''))
throw e
2018-03-14 16:36:12 +01:00
}
}