Display delete status errors

This commit is contained in:
tusooa 2023-01-20 12:33:19 -05:00 committed by Sam Therapy
parent e2dc1e7999
commit 818b424255
Signed by: sam
GPG key ID: 4D8B07C18F31ACBD
3 changed files with 16 additions and 4 deletions

View file

@ -970,6 +970,7 @@
"collapse_attachments": "Collapse attachments",
"copy_link": "Copy link to post",
"delete": "Delete post",
"delete_error": "Error deleting status: {0}",
"delete_confirm": "Do you really want to delete this post?",
"delete_confirm_accept_button": "Yes, delete it",
"delete_confirm_cancel_button": "No, keep it",

View file

@ -616,9 +616,19 @@ const statuses = {
fetchStatusHistory ({ rootState, dispatch }, status) {
return apiService.fetchStatusHistory({ status })
},
deleteStatus ({ rootState, commit }, status) {
commit('setDeleted', { status })
deleteStatus ({ rootState, commit, dispatch }, status) {
apiService.deleteStatus({ id: status.id, credentials: rootState.users.currentUser.credentials })
.then((_) => {
commit('setDeleted', { status })
})
.catch((e) => {
dispatch('pushGlobalNotice', {
level: 'error',
messageKey: 'status.delete_error',
messageArgs: [e.message],
timeout: 5000
})
})
},
deleteStatusById ({ rootState, commit }, id) {
const status = rootState.statuses.allStatusesObject[id]

View file

@ -981,8 +981,9 @@ const editStatus = ({
}
const deleteStatus = ({ id, credentials }) => {
return fetch(MASTODON_DELETE_URL(id), {
headers: authHeaders(credentials),
return promisedRequest({
url: MASTODON_DELETE_URL(id),
credentials,
method: 'DELETE'
})
}