import React, {useState, useMemo} from 'react' import { ActivityIndicator, Linking, StyleSheet, TouchableOpacity, View, } from 'react-native' import {ComAtprotoModerationDefs} from '@atproto/api' import LinearGradient from 'react-native-linear-gradient' import {useStores} from 'state/index' import {s, colors, gradients} from 'lib/styles' import {RadioGroup, RadioGroupItem} from '../util/forms/RadioGroup' import {Text} from '../util/text/Text' import * as Toast from '../util/Toast' import {ErrorMessage} from '../util/error/ErrorMessage' import {cleanError} from 'lib/strings/errors' import {usePalette} from 'lib/hooks/usePalette' const DMCA_LINK = 'https://bsky.app/support/copyright' export const snapPoints = [500] export function Component({ postUri, postCid, }: { postUri: string postCid: string }) { const store = useStores() const pal = usePalette('default') const [isProcessing, setIsProcessing] = useState(false) const [error, setError] = useState('') const [issue, setIssue] = useState('') const onSelectIssue = (v: string) => setIssue(v) const ITEMS: RadioGroupItem[] = useMemo( () => [ { key: ComAtprotoModerationDefs.REASONSPAM, label: ( Spam Excessive mentions or replies ), }, { key: ComAtprotoModerationDefs.REASONSEXUAL, label: ( Unwanted Sexual Content Nudity or pornography not labeled as such ), }, { key: '__copyright__', label: ( Copyright Violation Contains copyrighted material ), }, { key: ComAtprotoModerationDefs.REASONVIOLATION, label: ( Illegal and Urgent Glaring violations of law or terms of service ), }, { key: ComAtprotoModerationDefs.REASONOTHER, label: ( Other An issue not included in these options ), }, ], [pal], ) const onPress = async () => { setError('') if (!issue) { return } setIsProcessing(true) try { if (issue === '__copyright__') { Linking.openURL(DMCA_LINK) } else { await store.agent.createModerationReport({ reasonType: issue, subject: { $type: 'com.atproto.repo.strongRef', uri: postUri, cid: postCid, }, }) Toast.show("Thank you for your report! We'll look into it promptly.") } store.shell.closeModal() return } catch (e: any) { setError(cleanError(e)) setIsProcessing(false) } } return ( Report post What is the issue with this post? {error ? ( ) : undefined} {isProcessing ? ( ) : issue ? ( Send Report ) : undefined} ) } const styles = StyleSheet.create({ title: { textAlign: 'center', fontWeight: 'bold', fontSize: 24, marginBottom: 12, }, description: { textAlign: 'center', fontSize: 17, paddingHorizontal: 22, marginBottom: 10, }, btn: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', width: '100%', borderRadius: 32, padding: 14, backgroundColor: colors.gray1, }, })