diff --git a/src/components/moderation/LabelsOnMeDialog.tsx b/src/components/moderation/LabelsOnMeDialog.tsx
index e2a5d59f0b..1a5d988225 100644
--- a/src/components/moderation/LabelsOnMeDialog.tsx
+++ b/src/components/moderation/LabelsOnMeDialog.tsx
@@ -2,17 +2,19 @@ import React from 'react'
import {View} from 'react-native'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
-import {ComAtprotoLabelDefs} from '@atproto/api'
+import {ComAtprotoLabelDefs, ComAtprotoModerationDefs} from '@atproto/api'
import {useLabelInfo} from '#/lib/moderation/useLabelInfo'
import {makeProfileLink} from '#/lib/routes/links'
import {sanitizeHandle} from '#/lib/strings/handles'
+import {getAgent} from '#/state/session'
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
import {Text} from '#/components/Typography'
import * as Dialog from '#/components/Dialog'
import {Button, ButtonText} from '#/components/Button'
import {InlineLink} from '#/components/Link'
+import * as Toast from '#/view/com/util/Toast'
export {useDialogControl as useLabelsOnMeDialogControl} from '#/components/Dialog'
@@ -34,69 +36,66 @@ export interface LabelsOnMeDialogProps {
export function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) {
const {_} = useLingui()
const {gtMobile} = useBreakpoints()
+ const [appealingLabel, setAppealingLabel] = React.useState<
+ ComAtprotoLabelDefs.Label | undefined
+ >(undefined)
const {subject, labels} = props
const isAccount = 'did' in subject
- // TODO
- // const submit = async () => {
- // try {
- // const $type = !isAccountReport
- // ? 'com.atproto.repo.strongRef'
- // : 'com.atproto.admin.defs#repoRef'
- // await getAgent().createModerationReport({
- // reasonType: ComAtprotoModerationDefs.REASONAPPEAL,
- // subject: {
- // $type,
- // ...props,
- // },
- // reason: details,
- // })
- // Toast.show(_(msg`We'll look into your appeal promptly.`))
- // } finally {
- // closeModal()
- // }
- // }
-
return (
-
- {isAccount ? (
- Labels on your account
- ) : (
- Labels on your content
- )}
-
-
-
- You may appeal these labels if you feel they were placed in error.
-
-
+ {appealingLabel ? (
+ setAppealingLabel(undefined)}
+ />
+ ) : (
+ <>
+
+ {isAccount ? (
+ Labels on your account
+ ) : (
+ Labels on your content
+ )}
+
+
+
+ You may appeal these labels if you feel they were placed in error.
+
+
-
- {labels.map(label => (
-
- ))}
-
+
+ {labels.map(label => (
+
-
-
-
+
+
+
+ >
+ )}
)
}
@@ -114,9 +113,11 @@ export function LabelsOnMeDialog(props: LabelsOnMeDialogProps) {
function Label({
label,
control,
+ onPressAppeal,
}: {
label: ComAtprotoLabelDefs.Label
control: Dialog.DialogOuterProps['control']
+ onPressAppeal: (label: ComAtprotoLabelDefs.Label) => void
}) {
const t = useTheme()
const {_} = useLingui()
@@ -127,7 +128,6 @@ function Label({
style={[
a.p_md,
a.rounded_sm,
- // t.atoms.bg_contrast_25,
a.border,
t.atoms.border_contrast_low,
a.gap_sm,
@@ -142,8 +142,7 @@ function Label({
to={makeProfileLink(
labeler ? labeler.creator : {did: label.src, handle: ''},
)}
- onPress={() => control.close()}
- style={[]}>
+ onPress={() => control.close()}>
{labeler ? sanitizeHandle(labeler.creator.handle, '@') : label.src}
@@ -152,7 +151,8 @@ function Label({
variant="solid"
color="secondary"
size="small"
- label={_(msg`Appeal`)}>
+ label={_(msg`Appeal`)}
+ onPress={() => onPressAppeal(label)}>
Appeal
@@ -161,3 +161,106 @@ function Label({
)
}
+
+function AppealForm({
+ label,
+ subject,
+ control,
+ onPressBack,
+}: {
+ label: ComAtprotoLabelDefs.Label
+ subject: Subject
+ control: Dialog.DialogOuterProps['control']
+ onPressBack: () => void
+}) {
+ const {_} = useLingui()
+ const {labeler, strings} = useLabelInfo(label)
+ const {gtMobile} = useBreakpoints()
+ const [details, setDetails] = React.useState('')
+ const isAccountReport = 'did' in subject
+
+ const onSubmit = async () => {
+ try {
+ const $type = !isAccountReport
+ ? 'com.atproto.repo.strongRef'
+ : 'com.atproto.admin.defs#repoRef'
+ await getAgent().createModerationReport({
+ reasonType: ComAtprotoModerationDefs.REASONAPPEAL,
+ subject: {
+ $type,
+ ...subject,
+ },
+ reason: details,
+ })
+ Toast.show(_(msg`Appeal submitted.`))
+ } finally {
+ control.close()
+ }
+ }
+
+ return (
+ <>
+
+ Appeal "{strings.name}" label
+
+
+
+ This appeal will be sent to{' '}
+ control.close()}>
+ {labeler ? sanitizeHandle(labeler.creator.handle, '@') : label.src}
+
+ .
+
+
+
+
+
+
+
+
+
+
+ >
+ )
+}