import {useCallback, useState} from 'react' import {View} from 'react-native' import {ToolsOzoneReportDefs} from '@atproto/api' import {Trans, useLingui} from '@lingui/react/macro' import {useMutation} from '@tanstack/react-query' import {BLUESKY_MOD_SERVICE_HEADERS} from '#/lib/constants' import {logger} from '#/logger' import {useAgent, useSession} from '#/state/session' import {atoms as a, useBreakpoints, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import {Warning_Stroke2_Corner0_Rounded as WarningIcon} from '#/components/icons/Warning' import {Loader} from '#/components/Loader' import * as Toast from '#/components/Toast' import {Text} from '#/components/Typography' export function ChatDisabled() { const t = useTheme() return ( Your chats have been disabled Our moderators have reviewed reports and decided to disable your access to chats on Bluesky. ) } function AppealDialog() { const control = Dialog.useDialogControl() const {t: l} = useLingui() return ( <> ) } function DialogInner() { const {t: l} = useLingui() const control = Dialog.useDialogContext() const [details, setDetails] = useState('') const {gtMobile} = useBreakpoints() const agent = useAgent() const {currentAccount} = useSession() const {mutate, isPending} = useMutation({ mutationFn: async () => { if (!currentAccount) throw new Error('No current account, should be unreachable') await agent.createModerationReport( { reasonType: ToolsOzoneReportDefs.REASONAPPEAL, subject: { $type: 'com.atproto.admin.defs#repoRef', did: currentAccount.did, }, reason: details, }, { encoding: 'application/json', headers: BLUESKY_MOD_SERVICE_HEADERS, }, ) }, onError: err => { logger.error('Failed to submit chat appeal', {message: err}) Toast.show(l`Failed to submit appeal, please try again.`, { type: 'error', }) }, onSuccess: () => { control.close() Toast.show(l({message: 'Appeal submitted', context: 'toast'})) }, }) const onSubmit = useCallback(() => mutate(), [mutate]) const onBack = useCallback(() => control.close(), [control]) return ( Appeal this decision This appeal will be sent to Bluesky's moderation service. ) }