handle errors

This commit is contained in:
Henry Jameson 2026-09-04 00:17:24 +03:00
commit 4b04488ce0
2 changed files with 33 additions and 14 deletions

View file

@ -1742,6 +1742,7 @@
"approve_confirm_accept_button": "Approve", "approve_confirm_accept_button": "Approve",
"approve_confirm_cancel_button": "Do not approve", "approve_confirm_cancel_button": "Do not approve",
"approve_confirm": "Do you want to approve {user}'s follow request?", "approve_confirm": "Do you want to approve {user}'s follow request?",
"approve_error": "Failure approving follow request: {error}",
"block": "Block", "block": "Block",
"blocked": "Blocked!", "blocked": "Blocked!",
"block_confirm_title": "Block confirmation", "block_confirm_title": "Block confirmation",
@ -1754,6 +1755,7 @@
"deny_confirm_accept_button": "Deny", "deny_confirm_accept_button": "Deny",
"deny_confirm_cancel_button": "Do not deny", "deny_confirm_cancel_button": "Do not deny",
"deny_confirm": "Do you want to deny {user}'s follow request?", "deny_confirm": "Do you want to deny {user}'s follow request?",
"deny_error": "Failure denying follow request: {error}",
"edit_profile": "Edit profile", "edit_profile": "Edit profile",
"favorites": "Favorites", "favorites": "Favorites",
"follow": "Follow", "follow": "Follow",

View file

@ -4,6 +4,7 @@ import followRequestFetcher from 'src/stores/fetchers/follow_requests.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useNotificationsStore } from 'src/stores/notifications.js' import { useNotificationsStore } from 'src/stores/notifications.js'
import { useOAuthStore } from 'src/stores/oauth.js' import { useOAuthStore } from 'src/stores/oauth.js'
import { useInterfaceStore } from 'src/stores/interface.js'
import { approveUser, denyUser } from 'src/api/user.js' import { approveUser, denyUser } from 'src/api/user.js'
@ -79,27 +80,43 @@ export const useFollowRequestsStore = defineStore('followRequests', {
const id = userId ?? this.tempId const id = userId ?? this.tempId
this.hideApproveConfirmDialog() this.hideApproveConfirmDialog()
await approveUser({ try {
id, await approveUser({
credentials: useOAuthStore().token, id,
}) credentials: useOAuthStore().token,
})
const notifId = this.findFollowRequestNotificationId(id) const notifId = this.findFollowRequestNotificationId(id)
notifId && useNotificationsStore().markSingleNotificationAsSeen(notifId) notifId && useNotificationsStore().markSingleNotificationAsSeen(notifId)
this.requests.delete(id) this.requests.delete(id)
} catch (error) {
useInterfaceStore().pushGlobalNotice({
messageKey: 'user_card.approve_error',
messageArgs: { error },
level: 'error',
})
}
}, },
async doDeny(userId) { async doDeny(userId) {
const id = userId ?? this.tempId const id = userId ?? this.tempId
this.hideDenyConfirmDialog() this.hideDenyConfirmDialog()
await denyUser({ try {
id, await denyUser({
credentials: useOAuthStore().token, id,
}) credentials: useOAuthStore().token,
})
const notifId = this.findFollowRequestNotificationId(id) const notifId = this.findFollowRequestNotificationId(id)
notifId && useNotificationsStore().markSingleNotificationAsSeen(notifId) notifId && useNotificationsStore().markSingleNotificationAsSeen(notifId)
this.requests.delete(id) this.requests.delete(id)
} catch (error) {
useInterfaceStore().pushGlobalNotice({
messageKey: 'user_card.deny_error',
messageArgs: { error },
level: 'error',
})
}
}, },
// Utility // Utility