Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106import { useCallback, useEffect, useMemo, useReducer, useRef, useState,} from 'react'import {Pressable, type ScrollView, View} from 'react-native'import {api} from '@bsky/sdk'import {Trans, useLingui} from '@lingui/react/macro'
import {wait} from '#/lib/async/wait'import {formatTime} from '#/lib/media/video/formatTime'import {getLabelingServiceTitle} from '#/lib/moderation'import {useCallOnce} from '#/lib/once'import {sanitizeHandle} from '#/lib/strings/handles'import {useMyLabelersQuery} from '#/state/queries/preferences'import {CharProgress} from '#/view/com/composer/char-progress/CharProgress'import {UserAvatar} from '#/view/com/util/UserAvatar'import {atoms as a, useGutters, useTheme, web} from '#/alf'import * as Admonition from '#/components/Admonition'import {Button, ButtonIcon, ButtonText} from '#/components/Button'import * as Dialog from '#/components/Dialog'import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'import * as Toggle from '#/components/forms/Toggle'import {useDelayedLoading} from '#/components/hooks/useDelayedLoading'import {ArrowRotateCounterClockwise_Stroke2_Corner0_Rounded as Retry} from '#/components/icons/ArrowRotate'import { Check_Stroke2_Corner0_Rounded as CheckThin, CheckThick_Stroke2_Corner0_Rounded as Check,} from '#/components/icons/Check'import {PaperPlane_Stroke2_Corner0_Rounded as PaperPlane} from '#/components/icons/PaperPlane'import {SquareArrowTopRight_Stroke2_Corner0_Rounded as SquareArrowTopRight} from '#/components/icons/SquareArrowTopRight'import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'import {createStaticClick, InlineLinkText, Link} from '#/components/Link'import {Loader} from '#/components/Loader'import {Text} from '#/components/Typography'import {useAnalytics} from '#/analytics'import {IS_NATIVE} from '#/env'import {type app} from '#/lexicons'import {useSubmitReportMutation} from './action'import { BSKY_LABELER_ONLY_REPORT_REASONS, BSKY_LABELER_ONLY_SUBJECT_TYPES, NCII_FORM, NEW_TO_OLD_REASONS_MAP, SUPPORT_PAGE,} from './const'import {useCopyForSubject} from './copy'import {classifyReportError} from './errors'import {useReportDialogMetadataContext} from './ReportDialogMetadataContext'import { getNciiQualificationOutcome, initialState, type NciiQualification as NciiQualificationState, reducer, type ReportAction,} from './state'import {type ReportDialogProps, type ReportSubject} from './types'import {parseReportSubject} from './utils/parseReportSubject'import { type ReportCategoryConfig, type ReportOption, useReportOptions,} from './utils/useReportOptions'
export {useCopyForSubject, useGetCopyForSubject} from './copy'export {type ReportSubject} from './types'export { getAssociatedReportSubjects, parseReportSubject,} from './utils/parseReportSubject'export {useDialogControl as useReportDialogControl} from '#/components/Dialog'
export function useGlobalReportDialogControl() { return useGlobalDialogsControlContext().reportDialogControl}
export function GlobalReportDialog() { const {value, control} = useGlobalReportDialogControl() return <ReportDialog control={control} subject={value?.subject} />}
export function ReportDialog( props: Omit<ReportDialogProps, 'subject'> & { subject?: ReportSubject },) { const ax = useAnalytics() const reportDialogMetadata = useReportDialogMetadataContext() const subject = useMemo( () => (props.subject ? parseReportSubject(props.subject) : undefined), [props.subject], ) const [presentation, setPresentation] = useState<{ openCount: number videoTimestampSeconds?: number }>({openCount: 0}) const onOpen = () => { const seconds = subject?.type === 'post' && subject.attributes.video ? reportDialogMetadata?.current.videoTimestampSeconds : undefined
setPresentation(current => ({ openCount: current.openCount + 1, // Values below one second indicate that the video was never meaningfully // played, so avoid offering to attach a noisy "0:00" timestamp. videoTimestampSeconds: seconds !== undefined && seconds >= 1 ? Math.floor(seconds) : undefined, })) } const propsOnClose = props.onClose const onClose = useCallback(() => { ax.metric('reportDialog:close', {}) propsOnClose?.() }, [ax, propsOnClose]) return ( <Dialog.Outer control={props.control} onOpen={onOpen} onClose={onClose}> <Dialog.Handle /> {subject ? ( <Inner key={presentation.openCount} {...props} subject={subject} videoTimestampSeconds={presentation.videoTimestampSeconds} /> ) : ( <Invalid /> )} </Dialog.Outer> )}
/** * This should only be shown if the dialog is configured incorrectly by a * developer, but nevertheless we should have a graceful fallback. */function Invalid() { const {t: l} = useLingui() return ( <Dialog.ScrollableInner label={l`Report dialog`}> <Text style={[a.font_bold, a.text_xl, a.leading_snug, a.pb_xs]}> <Trans>Invalid report subject</Trans> </Text> <Text style={[a.text_md, a.leading_snug]}> <Trans> Something wasn't quite right with the data you're trying to report. Please contact support. </Trans> </Text> <Dialog.Close /> </Dialog.ScrollableInner> )}
function Inner( props: ReportDialogProps & { videoTimestampSeconds?: number },) { const ax = useAnalytics() const logger = ax.logger.useChild(ax.logger.Context.ReportDialog) const t = useTheme() const {t: l} = useLingui() const ref = useRef<React.ComponentRef<typeof ScrollView>>(null) const { data: allLabelers, isLoading: isLabelerLoading, error: labelersLoadError, refetch: refetchLabelers, } = useMyLabelersQuery({excludeNonConfigurableLabelers: true}) const isLoading = useDelayedLoading(500, isLabelerLoading) const copy = useCopyForSubject(props.subject) const {categories, getCategory} = useReportOptions() const [state, dispatch] = useReducer(reducer, initialState)
/** * Submission handling */ const {mutateAsync: submitReport} = useSubmitReportMutation() const [isPending, setIsPending] = useState(false) const [isSuccess, setIsSuccess] = useState(false)
const {videoTimestampSeconds} = props
// some reasons ONLY go to Bluesky const isBskyOnlyReason = state?.selectedOption?.reason ? BSKY_LABELER_ONLY_REPORT_REASONS.has(state.selectedOption.reason) : false // some subjects ONLY go to Bluesky const isBskyOnlySubject = BSKY_LABELER_ONLY_SUBJECT_TYPES.has( props.subject.type, )
/** * Labelers that support this `subject` and its NSID collection */ const supportedLabelers = useMemo(() => { if (!allLabelers) return [] return allLabelers .filter(l => { const subjectTypes: string[] | undefined = l.subjectTypes if (subjectTypes === undefined) return true if (props.subject.type === 'account') { return subjectTypes.includes('account') } else if ( props.subject.type === 'convoMessage' || props.subject.type === 'convo' ) { return subjectTypes.includes('chat') } else { return subjectTypes.includes('record') } }) .filter(l => { const collections: string[] | undefined = l.subjectCollections if (collections === undefined) return true // all chat collections accepted, since only Bluesky handles chats if ( props.subject.type === 'convoMessage' || props.subject.type === 'convo' ) return true return collections.includes(props.subject.nsid) }) .filter(l => { if (!state.selectedOption) return false if (isBskyOnlyReason || isBskyOnlySubject) { return l.creator.did === api.moderation.did } const supportedReasonTypes: string[] | undefined = l.reasonTypes if (supportedReasonTypes === undefined) return true return ( // supports new reason type // supports old reason type (backwards compat) supportedReasonTypes.includes(state.selectedOption.reason) || supportedReasonTypes.includes( NEW_TO_OLD_REASONS_MAP[state.selectedOption.reason], ) ) }) }, [ props.subject, allLabelers, state.selectedOption, isBskyOnlyReason, isBskyOnlySubject, ]) const hasSupportedLabelers = !!supportedLabelers.length const hasSingleSupportedLabeler = supportedLabelers.length === 1
/** * We skip the select labeler step if there's only one possible labeler, and * that labeler is Bluesky (which is the case for chat reports and certain * reason types). We'll use this below to adjust the indexing and skip the * step in the UI. */ const isAlwaysBskyLabeler = hasSingleSupportedLabeler && (isBskyOnlyReason || isBskyOnlySubject)
const onSubmit = useCallback(async () => { dispatch({type: 'clearError'})
logger.info('submitting')
try { setIsPending(true) // wait at least 1s, make it feel substantial await wait( 1e3, submitReport({ subject: props.subject, state, videoTimestampSeconds, }), ) setIsSuccess(true) ax.metric('reportDialog:success', { subjectType: props.subject.type, reason: state.selectedOption?.reason ?? '', labeler: state.selectedLabeler?.creator.handle ?? '', details: !!state.details, videoTimestamp: state.includeVideoTimestamp, }) // give time for user feedback setTimeout(() => { props.control.close(() => { props.onAfterSubmit?.() }) }, 1e3) } catch (err) { const e = err instanceof Error ? err : new Error(String(err)) const classification = classifyReportError(e) const tags = { ...classification.tags, report_subject_type: props.subject.type, report_labeler: state.selectedLabeler?.creator.did, report_reason: state.selectedOption?.reason, }
ax.metric('reportDialog:failure', {})
if (classification.shouldReport) { logger.error(e, { source: 'ReportDialog', fingerprint: classification.fingerprint, tags, }) } else { logger.warn('Report rejected for taken down account', {tags}) }
let error = l`Something went wrong. Please try again.` if (classification.kind === 'account-takedown') { error = l`Your account cannot submit reports while it is suspended.` } else if (classification.kind === 'invalid-reason-type') { error = l`This moderation service does not support that report reason. Please choose a different reason or moderation service.` } else if (classification.kind === 'service-unavailable') { error = l`The moderation service is temporarily unavailable. Please try again later.` }
dispatch({ type: 'setError', error, }) } setIsPending(false) }, [logger, submitReport, props, state, ax, l, videoTimestampSeconds])
useCallOnce(() => { ax.metric('reportDialog:open', { subjectType: props.subject.type, }) })()
return ( <Dialog.ScrollableInner testID="report:dialog" label={l`Report dialog`} ref={ref} style={[a.w_full, web({maxWidth: 500})]}> <View style={[a.gap_2xl, IS_NATIVE && a.pt_md]}> <StepOuter> <StepTitle index={1} title={copy.subtitle} activeIndex1={state.activeStepIndex1} /> {isLoading ? ( <View style={[a.gap_sm]}> <OptionCardSkeleton /> <OptionCardSkeleton /> <OptionCardSkeleton /> <OptionCardSkeleton /> <OptionCardSkeleton /> {/* Here to capture focus for a hot sec to prevent flash */} <Pressable accessible={false} /> </View> ) : labelersLoadError || !allLabelers ? ( <Admonition.Outer type="error"> <Admonition.Row> <Admonition.Icon /> <Admonition.Content> <Admonition.Text> <Trans>Something went wrong, please try again</Trans> </Admonition.Text> </Admonition.Content> <Admonition.Button color="negative_subtle" label={l`Retry loading report options`} onPress={() => void refetchLabelers()}> <ButtonText> <Trans>Retry</Trans> </ButtonText> <ButtonIcon icon={Retry} /> </Admonition.Button> </Admonition.Row> </Admonition.Outer> ) : ( <> {state.selectedCategory ? ( <View style={[a.flex_row, a.align_center, a.gap_md]}> <View style={[a.flex_1]}> <CategoryCard option={state.selectedCategory} /> </View> <Button testID="report:clearCategory" label={l`Change report category`} size="tiny" variant="solid" color="secondary" shape="round" onPress={() => { dispatch({type: 'clearCategory'}) }}> <ButtonIcon icon={X} /> </Button> </View> ) : ( <View style={[a.gap_sm]}> {categories.map(o => ( <CategoryCard key={o.key} option={o} onSelect={() => { dispatch({ type: 'selectCategory', option: o, otherOption: getCategory('other').options[0], }) }} /> ))}
{['post', 'account'].includes(props.subject.type) && ( <Link to={SUPPORT_PAGE} label={l`Need to report a copyright violation, legal request, or regulatory compliance issue?`}> {({hovered, pressed}) => ( <View style={[ a.flex_row, a.align_center, a.w_full, a.px_md, a.py_sm, a.rounded_sm, a.border, hovered || pressed ? [t.atoms.border_contrast_high] : [t.atoms.border_contrast_low], ]}> <Text style={[a.flex_1, a.italic, a.leading_snug]}> <Trans> Need to report a copyright violation, legal request, or regulatory compliance issue? </Trans> </Text> <SquareArrowTopRight size="sm" fill={t.atoms.text.color} /> </View> )} </Link> )} </View> )} </> )} </StepOuter>
<StepOuter> <StepTitle index={2} title={l`Select a reason`} activeIndex1={state.activeStepIndex1} /> {state.selectedOption ? ( <> <View style={[a.flex_row, a.align_center, a.gap_md]}> <View style={[a.flex_1]}> <OptionCard option={state.selectedOption} /> </View> <Button testID="report:clearReportOption" label={l`Change report reason`} size="tiny" variant="solid" color="secondary" shape="round" onPress={() => { dispatch({type: 'clearOption'}) }}> <ButtonIcon icon={X} /> </Button> </View> {state.ncii && ( <NciiQualification ncii={state.ncii} dispatch={dispatch} /> )} </> ) : state.selectedCategory ? ( <View style={[a.gap_sm]}> {getCategory(state.selectedCategory.key).options.map(o => ( <OptionCard key={o.reason} option={o} onSelect={() => { dispatch({type: 'selectOption', option: o}) }} /> ))} </View> ) : null} </StepOuter>
{isAlwaysBskyLabeler ? ( <ActionOnce check={() => !state.selectedLabeler} callback={() => { dispatch({ type: 'selectLabeler', labeler: supportedLabelers[0], }) }} /> ) : ( <StepOuter> <StepTitle index={3} title={l`Select moderation service`} activeIndex1={state.activeStepIndex1} /> {state.activeStepIndex1 >= 3 && ( <> {state.selectedLabeler ? ( <> {hasSingleSupportedLabeler ? ( <LabelerCard labeler={state.selectedLabeler} /> ) : ( <View style={[a.flex_row, a.align_center, a.gap_md]}> <View style={[a.flex_1]}> <LabelerCard labeler={state.selectedLabeler} /> </View> <Button label={l`Change moderation service`} size="tiny" variant="solid" color="secondary" shape="round" onPress={() => { dispatch({type: 'clearLabeler'}) }}> <ButtonIcon icon={X} /> </Button> </View> )} </> ) : ( <> {hasSupportedLabelers ? ( <View style={[a.gap_sm]}> {hasSingleSupportedLabeler ? ( <> <LabelerCard labeler={supportedLabelers[0]} /> <ActionOnce check={() => !state.selectedLabeler} callback={() => { dispatch({ type: 'selectLabeler', labeler: supportedLabelers[0], }) }} /> </> ) : ( <> {supportedLabelers.map(l => ( <LabelerCard key={l.creator.did} labeler={l} onSelect={() => { dispatch({type: 'selectLabeler', labeler: l}) }} /> ))} </> )} </View> ) : ( // should never happen in our app <Admonition.Admonition type="warning"> <Trans> Unfortunately, none of your subscribed labelers supports this report type. </Trans> </Admonition.Admonition> )} </> )} </> )} </StepOuter> )}
<StepOuter> <StepTitle index={isAlwaysBskyLabeler ? 3 : 4} title={l`Submit report`} activeIndex1={ isAlwaysBskyLabeler ? state.activeStepIndex1 - 1 : state.activeStepIndex1 } /> {state.activeStepIndex1 === 4 && ( <> <View style={[a.pb_xs, a.gap_xs]}> <Text style={[a.leading_snug, a.pb_xs]}> <Trans> Your report will be sent to{' '} <Text style={[a.font_semi_bold, a.leading_snug]}> {state.selectedLabeler?.creator.displayName} </Text> . </Trans>{' '} {!state.detailsOpen ? ( <InlineLinkText label={l`Add more details (optional)`} {...createStaticClick(() => { dispatch({type: 'showDetails'}) })}> <Trans>Add more details (optional)</Trans> </InlineLinkText> ) : null} </Text>
{state.detailsOpen && ( <View> <Dialog.Input testID="report:details" multiline value={state.details} onChangeText={details => { dispatch({type: 'setDetails', details}) }} label={l`Additional details (limit 300 characters)`} style={{paddingRight: 60}} numberOfLines={4} /> <View style={[ a.absolute, a.flex_row, a.align_center, a.pr_md, a.pb_sm, { bottom: 0, right: 0, }, ]}> <CharProgress count={state.details?.length || 0} /> </View> </View> )} </View>
{videoTimestampSeconds !== undefined && state.selectedLabeler?.creator.did === api.moderation.did && ( <IncludeVideoTimestampToggle seconds={videoTimestampSeconds} selected={state.includeVideoTimestamp} onChange={include => { dispatch({type: 'setIncludeVideoTimestamp', include}) }} /> )}
<Button testID="report:submit" label={l`Submit report`} size="large" variant="solid" color="primary" disabled={isPending || isSuccess} onPress={() => void onSubmit()}> <ButtonText> <Trans>Submit report</Trans> </ButtonText> <ButtonIcon icon={isSuccess ? CheckThin : isPending ? Loader : PaperPlane} /> </Button>
{state.error && ( <Admonition.Admonition type="error"> {state.error} </Admonition.Admonition> )} </> )} </StepOuter> </View> <Dialog.Close /> </Dialog.ScrollableInner> )}
/** * Opt-in for attaching how far the viewer had watched to a video report. Only * rendered once we have a position and the report is going to Bluesky. */function IncludeVideoTimestampToggle({ seconds, selected, onChange,}: { seconds: number selected: boolean onChange: (selected: boolean) => void}) { const {t: l} = useLingui() const videoTimestamp = formatTime(seconds) const label = l({ message: `Include video timestamp (${videoTimestamp})`, comment: 'Checkbox shown when reporting a video. The value is the current playback position, formatted as minutes:seconds.', }) return ( <Toggle.Item testID="report:includeVideoTimestamp" name="includeVideoTimestamp" type="checkbox" label={label} value={selected} onChange={onChange}> <Toggle.Checkbox /> <Toggle.LabelText style={[a.flex_1, a.font_normal, a.leading_snug]}> {label} </Toggle.LabelText> </Toggle.Item> )}
function ActionOnce({ check, callback,}: { check: () => boolean callback: () => void}) { useEffect(() => { if (check()) { callback() } }, [check, callback]) return null}
function StepOuter({children}: {children: React.ReactNode}) { return <View style={[a.gap_md, a.w_full]}>{children}</View>}
function StepTitle({ index, title, activeIndex1,}: { index: number title: string activeIndex1: number}) { const t = useTheme() const active = activeIndex1 === index const completed = activeIndex1 > index return ( <View style={[a.flex_row, a.gap_sm, a.pr_3xl]}> <View style={[ a.justify_center, a.align_center, a.rounded_full, a.border, { width: 24, height: 24, backgroundColor: active ? t.palette.primary_500 : completed ? t.palette.primary_100 : t.atoms.bg_contrast_25.backgroundColor, borderColor: active ? t.palette.primary_500 : completed ? t.palette.primary_400 : t.atoms.border_contrast_low.borderColor, }, ]}> {completed ? ( <Check width={12} /> ) : ( <Text style={[ a.font_bold, a.text_center, t.atoms.text, { color: active ? 'white' : completed ? t.palette.primary_700 : t.atoms.text_contrast_medium.color, fontVariant: ['tabular-nums'], width: 24, height: 24, lineHeight: 24, }, ]}> {index} </Text> )} </View>
<Text style={[ a.flex_1, a.font_bold, a.text_lg, a.leading_snug, active ? t.atoms.text : t.atoms.text_contrast_medium, { top: 1, }, ]}> {title} </Text> </View> )}
function CategoryCard({ option, onSelect,}: { option: ReportCategoryConfig onSelect?: (option: ReportCategoryConfig) => void}) { const t = useTheme() const {t: l} = useLingui() const gutters = useGutters(['compact']) const onPress = useCallback(() => { onSelect?.(option) }, [onSelect, option]) return ( <Button testID={`report:category:${option.title}`} label={l`Create report for ${option.title}`} onPress={onPress} disabled={!onSelect}> {({hovered, pressed}) => ( <View style={[ a.w_full, gutters, a.py_sm, a.rounded_sm, a.border, t.atoms.bg_contrast_25, hovered || pressed ? [t.atoms.border_contrast_high] : [t.atoms.border_contrast_low], ]}> <Text style={[a.text_md, a.font_semi_bold, a.leading_snug]}> {option.title} </Text> <Text style={[a.text_sm, , a.leading_snug, t.atoms.text_contrast_medium]}> {option.description} </Text> </View> )} </Button> )}
function OptionCard({ option, onSelect,}: { option: ReportOption onSelect?: (option: ReportOption) => void}) { const t = useTheme() const {t: l} = useLingui() const gutters = useGutters(['compact']) const onPress = useCallback(() => { onSelect?.(option) }, [onSelect, option]) return ( <Button testID={`report:option:${option.title}`} label={l({ message: `Create report for ${option.title}`, comment: 'Accessibility label for button to create a moderation report for the selected option', })} onPress={onPress} disabled={!onSelect}> {({hovered, pressed}) => ( <View style={[ a.w_full, gutters, a.py_sm, a.rounded_sm, a.border, t.atoms.bg_contrast_25, hovered || pressed ? [t.atoms.border_contrast_high] : [t.atoms.border_contrast_low], ]}> <Text style={[a.text_md, a.font_semi_bold, a.leading_snug]}> {option.title} </Text> </View> )} </Button> )}
/** * Qualifying question shown when the NCII reason is selected. The depicted * person (or their authorized representative) is directed to the external * NCII report form; everyone else continues with the normal in-app * submission. */function NciiQualification({ ncii, dispatch,}: { ncii: NciiQualificationState dispatch: React.Dispatch<ReportAction>}) { const t = useTheme() const {t: l} = useLingui() const outcome = getNciiQualificationOutcome(ncii) return ( <View style={[a.gap_md]}> <YesNoQuestion testID="report:ncii:isDepicted" question={l`Are you the person depicted, or an authorized representative acting on behalf of the person depicted?`} value={ncii.isDepicted} onAnswer={answer => { dispatch({ type: 'answerNciiQuestion', question: 'isDepicted', answer, }) }} /> {outcome === 'externalForm' && ( <Link to={NCII_FORM} label={l({ message: 'Submit your report through the Report non-consensual intimate imagery (NCII) form', context: 'english-only-resource', })}> {({hovered, pressed}) => ( <View style={[ a.flex_row, a.align_center, a.w_full, a.px_md, a.py_sm, a.rounded_sm, a.border, hovered || pressed ? [t.atoms.border_contrast_high] : [t.atoms.border_contrast_low], ]}> <Text style={[a.flex_1, a.italic, a.leading_snug]}> <Trans context="english-only-resource"> Please submit your report through the Report non-consensual intimate imagery (NCII) form. </Trans> </Text> <SquareArrowTopRight size="sm" fill={t.atoms.text.color} /> </View> )} </Link> )} </View> )}
function YesNoQuestion({ question, value, onAnswer, testID,}: { question: string value?: boolean onAnswer: (answer: boolean) => void testID?: string}) { const {t: l} = useLingui() return ( <View style={[a.gap_sm]}> <Text style={[a.text_sm, a.leading_snug]}>{question}</Text> <View style={[a.flex_row, a.gap_sm]}> <View style={[a.flex_1]}> <Button testID={testID ? `${testID}:yes` : undefined} label={l({ message: 'Yes', context: 'Answer to a yes/no question', })} accessibilityHint={question} size="small" color={value === true ? 'primary' : 'secondary'} onPress={() => onAnswer(true)}> <ButtonText> <Trans context="Answer to a yes/no question">Yes</Trans> </ButtonText> </Button> </View> <View style={[a.flex_1]}> <Button testID={testID ? `${testID}:no` : undefined} label={l({ message: 'No', context: 'Answer to a yes/no question', })} accessibilityHint={question} size="small" color={value === false ? 'primary' : 'secondary'} onPress={() => onAnswer(false)}> <ButtonText> <Trans context="Answer to a yes/no question">No</Trans> </ButtonText> </Button> </View> </View> </View> )}
function OptionCardSkeleton() { const t = useTheme() return ( <View style={[ a.w_full, a.rounded_sm, a.border, t.atoms.bg_contrast_25, t.atoms.border_contrast_low, {height: 55}, // magic, based on web ]} /> )}
function LabelerCard({ labeler, onSelect,}: { labeler: app.bsky.labeler.defs.LabelerViewDetailed onSelect?: (option: app.bsky.labeler.defs.LabelerViewDetailed) => void}) { const t = useTheme() const {t: l} = useLingui() const onPress = useCallback(() => { onSelect?.(labeler) }, [onSelect, labeler]) const title = getLabelingServiceTitle({ displayName: labeler.creator.displayName, handle: labeler.creator.handle, }) return ( <Button testID={`report:labeler:${labeler.creator.handle}`} label={l`Send report to ${title}`} onPress={onPress} disabled={!onSelect}> {({hovered, pressed}) => ( <View style={[ a.w_full, a.p_sm, a.flex_row, a.align_center, a.gap_sm, a.rounded_md, a.border, t.atoms.bg_contrast_25, hovered || pressed ? [t.atoms.border_contrast_high] : [t.atoms.border_contrast_low], ]}> <UserAvatar type="labeler" size={36} avatar={labeler.creator.avatar} /> <View style={[a.flex_1]}> <Text style={[a.text_md, a.font_semi_bold, a.leading_snug]}> {title} </Text> <Text style={[a.text_sm, a.leading_snug, t.atoms.text_contrast_medium]}> <Trans>By {sanitizeHandle(labeler.creator.handle, '@')}</Trans> </Text> </View> </View> )} </Button> )}