From d1876503bc560b9c62d03e219021593cb954fcf4 Mon Sep 17 00:00:00 2001 From: tusooa Date: Fri, 20 Jan 2023 12:33:19 -0500 Subject: [PATCH] Display delete status errors --- src/i18n/en.json | 1 + src/modules/statuses.js | 14 ++++++++++++-- src/services/api/api.service.js | 5 +++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/i18n/en.json b/src/i18n/en.json index 1ee1147ad3..5e653ad8c1 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -844,6 +844,7 @@ "favorites": "Favorites", "repeats": "Repeats", "delete": "Delete status", + "delete_error": "Error deleting status: {0}", "edit": "Edit status", "edited_at": "(last edited {time})", "pin": "Pin on profile", diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 77dd7e1c2d..93a4a957c5 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -615,9 +615,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] diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index af12265e89..609f6790ae 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -923,8 +923,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' }) }