logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: 9c376b3511e0922ba9bfb8941dfb47149656b04e
parent ad5bd09204b30b601f5bbfdf51044363386dfd6a
Author: HJ <30-hj@users.noreply.git.pleroma.social>
Date:   Tue, 11 Apr 2023 21:26:16 +0000

Merge branch 'tusooa/1244-report-delete-fail' into 'develop'

Display delete status errors

Closes #1244

See merge request pleroma/pleroma-fe!1769

Diffstat:

Msrc/i18n/en.json1+
Msrc/modules/statuses.js14++++++++++++--
Msrc/services/api/api.service.js5+++--
3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/i18n/en.json b/src/i18n/en.json @@ -879,6 +879,7 @@ "repeat_confirm_accept_button": "Repeat", "repeat_confirm_cancel_button": "Do not repeat", "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 @@ -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 @@ -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' }) }