diff --git a/src/components/moderation/LabelsOnMeDialog.tsx b/src/components/moderation/LabelsOnMeDialog.tsx index c817431117..ceee4cf9dc 100644 --- a/src/components/moderation/LabelsOnMeDialog.tsx +++ b/src/components/moderation/LabelsOnMeDialog.tsx @@ -1,6 +1,7 @@ -import React from 'react' +import React, {useState} from 'react' import {View} from 'react-native' import {type ComAtprotoLabelDefs, ComAtprotoModerationDefs} from '@atproto/api' +import {XRPCError} from '@atproto/xrpc' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useMutation} from '@tanstack/react-query' @@ -19,6 +20,7 @@ import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import {InlineLinkText} from '#/components/Link' import {Text} from '#/components/Typography' +import {Admonition} from '../Admonition' import {Divider} from '../Divider' import {Loader} from '../Loader' @@ -228,6 +230,7 @@ function AppealForm({ const sourceName = labeler ? sanitizeHandle(labeler.creator.handle, '@') : label.src + const [error, setError] = useState(null) const {mutate, isPending} = useMutation({ mutationFn: async () => { @@ -252,8 +255,16 @@ function AppealForm({ ) }, onError: err => { + if (err instanceof XRPCError && err.error === 'AlreadyAppealed') { + setError( + _( + msg`You've already appealed this label and it's being reviewed by our moderation team.`, + ), + ) + } else { + setError(_(msg`Failed to submit appeal, please try again.`)) + } logger.error('Failed to submit label appeal', {message: err}) - Toast.show(_(msg`Failed to submit appeal, please try again.`), 'xmark') }, onSuccess: () => { control.close() @@ -285,6 +296,11 @@ function AppealForm({ + {error && ( + + {error} + + )}