From 4b04488ce081f8be3674f04500a2cc8772add7fc Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Fri, 4 Sep 2026 00:17:24 +0300 Subject: [PATCH] handle errors --- src/i18n/en.json | 2 ++ src/stores/follow_requests.js | 45 ++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/i18n/en.json b/src/i18n/en.json index 0e861fe77..82c2c2637 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -1742,6 +1742,7 @@ "approve_confirm_accept_button": "Approve", "approve_confirm_cancel_button": "Do not approve", "approve_confirm": "Do you want to approve {user}'s follow request?", + "approve_error": "Failure approving follow request: {error}", "block": "Block", "blocked": "Blocked!", "block_confirm_title": "Block confirmation", @@ -1754,6 +1755,7 @@ "deny_confirm_accept_button": "Deny", "deny_confirm_cancel_button": "Do not deny", "deny_confirm": "Do you want to deny {user}'s follow request?", + "deny_error": "Failure denying follow request: {error}", "edit_profile": "Edit profile", "favorites": "Favorites", "follow": "Follow", diff --git a/src/stores/follow_requests.js b/src/stores/follow_requests.js index 647821782..733d5cd63 100644 --- a/src/stores/follow_requests.js +++ b/src/stores/follow_requests.js @@ -4,6 +4,7 @@ import followRequestFetcher from 'src/stores/fetchers/follow_requests.js' import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useNotificationsStore } from 'src/stores/notifications.js' import { useOAuthStore } from 'src/stores/oauth.js' +import { useInterfaceStore } from 'src/stores/interface.js' import { approveUser, denyUser } from 'src/api/user.js' @@ -79,27 +80,43 @@ export const useFollowRequestsStore = defineStore('followRequests', { const id = userId ?? this.tempId this.hideApproveConfirmDialog() - await approveUser({ - id, - credentials: useOAuthStore().token, - }) + try { + await approveUser({ + id, + credentials: useOAuthStore().token, + }) - const notifId = this.findFollowRequestNotificationId(id) - notifId && useNotificationsStore().markSingleNotificationAsSeen(notifId) - this.requests.delete(id) + const notifId = this.findFollowRequestNotificationId(id) + notifId && useNotificationsStore().markSingleNotificationAsSeen(notifId) + this.requests.delete(id) + } catch (error) { + useInterfaceStore().pushGlobalNotice({ + messageKey: 'user_card.approve_error', + messageArgs: { error }, + level: 'error', + }) + } }, async doDeny(userId) { const id = userId ?? this.tempId this.hideDenyConfirmDialog() - await denyUser({ - id, - credentials: useOAuthStore().token, - }) + try { + await denyUser({ + id, + credentials: useOAuthStore().token, + }) - const notifId = this.findFollowRequestNotificationId(id) - notifId && useNotificationsStore().markSingleNotificationAsSeen(notifId) - this.requests.delete(id) + const notifId = this.findFollowRequestNotificationId(id) + notifId && useNotificationsStore().markSingleNotificationAsSeen(notifId) + this.requests.delete(id) + } catch (error) { + useInterfaceStore().pushGlobalNotice({ + messageKey: 'user_card.deny_error', + messageArgs: { error }, + level: 'error', + }) + } }, // Utility