Bluesky app fork with some witchin' additions 💫

use admonition instead of toast for errors when appealing labels (#9272)

* use admonition instead of toast for errors when appealing labels

* address commments

authored by

Chenyu and committed by
GitHub
d58c6c9e bd5d1028

+18 -2
+18 -2
src/components/moderation/LabelsOnMeDialog.tsx
··· 1 - import React from 'react' 1 + import React, {useState} from 'react' 2 2 import {View} from 'react-native' 3 3 import {type ComAtprotoLabelDefs, ComAtprotoModerationDefs} from '@atproto/api' 4 + import {XRPCError} from '@atproto/xrpc' 4 5 import {msg, Trans} from '@lingui/macro' 5 6 import {useLingui} from '@lingui/react' 6 7 import {useMutation} from '@tanstack/react-query' ··· 19 20 import * as Dialog from '#/components/Dialog' 20 21 import {InlineLinkText} from '#/components/Link' 21 22 import {Text} from '#/components/Typography' 23 + import {Admonition} from '../Admonition' 22 24 import {Divider} from '../Divider' 23 25 import {Loader} from '../Loader' 24 26 ··· 228 230 const sourceName = labeler 229 231 ? sanitizeHandle(labeler.creator.handle, '@') 230 232 : label.src 233 + const [error, setError] = useState<string | null>(null) 231 234 232 235 const {mutate, isPending} = useMutation({ 233 236 mutationFn: async () => { ··· 252 255 ) 253 256 }, 254 257 onError: err => { 258 + if (err instanceof XRPCError && err.error === 'AlreadyAppealed') { 259 + setError( 260 + _( 261 + msg`You've already appealed this label and it's being reviewed by our moderation team.`, 262 + ), 263 + ) 264 + } else { 265 + setError(_(msg`Failed to submit appeal, please try again.`)) 266 + } 255 267 logger.error('Failed to submit label appeal', {message: err}) 256 - Toast.show(_(msg`Failed to submit appeal, please try again.`), 'xmark') 257 268 }, 258 269 onSuccess: () => { 259 270 control.close() ··· 285 296 </Trans> 286 297 </Text> 287 298 </View> 299 + {error && ( 300 + <Admonition type="error" style={[a.mt_sm]}> 301 + {error} 302 + </Admonition> 303 + )} 288 304 <View style={[a.my_md]}> 289 305 <Dialog.Input 290 306 label={_(msg`Text input field`)}