handle errors
This commit is contained in:
parent
da53e35817
commit
4b04488ce0
2 changed files with 33 additions and 14 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue