diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/moderation/LabelsOnMe.tsx | 4 | ||||
-rw-r--r-- | src/components/moderation/LabelsOnMeDialog.tsx | 96 |
2 files changed, 62 insertions, 38 deletions
diff --git a/src/components/moderation/LabelsOnMe.tsx b/src/components/moderation/LabelsOnMe.tsx index ea5c74f9e..77d0e2d93 100644 --- a/src/components/moderation/LabelsOnMe.tsx +++ b/src/components/moderation/LabelsOnMe.tsx @@ -32,9 +32,7 @@ export function LabelsOnMe({ if (!labels || !currentAccount) { return null } - labels = labels.filter( - l => !l.val.startsWith('!') && l.src !== currentAccount.did, - ) + labels = labels.filter(l => !l.val.startsWith('!')) if (!labels.length) { return null } diff --git a/src/components/moderation/LabelsOnMeDialog.tsx b/src/components/moderation/LabelsOnMeDialog.tsx index 176b04941..858ac9ce4 100644 --- a/src/components/moderation/LabelsOnMeDialog.tsx +++ b/src/components/moderation/LabelsOnMeDialog.tsx @@ -7,7 +7,7 @@ import {useLingui} from '@lingui/react' import {useLabelInfo} from '#/lib/moderation/useLabelInfo' import {makeProfileLink} from '#/lib/routes/links' import {sanitizeHandle} from '#/lib/strings/handles' -import {useAgent} from '#/state/session' +import {useAgent, useSession} from '#/state/session' import * as Toast from '#/view/com/util/Toast' import {atoms as a, useBreakpoints, useTheme} from '#/alf' import {Button, ButtonText} from '#/components/Button' @@ -33,13 +33,28 @@ export interface LabelsOnMeDialogProps { labels: ComAtprotoLabelDefs.Label[] } -export function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) { +export function LabelsOnMeDialog(props: LabelsOnMeDialogProps) { + return ( + <Dialog.Outer control={props.control}> + <Dialog.Handle /> + + <LabelsOnMeDialogInner {...props} /> + </Dialog.Outer> + ) +} + +function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) { const {_} = useLingui() + const {currentAccount} = useSession() const [appealingLabel, setAppealingLabel] = React.useState< ComAtprotoLabelDefs.Label | undefined >(undefined) const {subject, labels} = props const isAccount = 'did' in subject + const containsSelfLabel = React.useMemo( + () => labels.some(l => l.src === currentAccount?.did), + [currentAccount?.did, labels], + ) return ( <Dialog.ScrollableInner @@ -65,9 +80,17 @@ export function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) { )} </Text> <Text style={[a.text_md, a.leading_snug]}> - <Trans> - You may appeal these labels if you feel they were placed in error. - </Trans> + {containsSelfLabel ? ( + <Trans> + You may appeal non-self labels if you feel they were placed in + error. + </Trans> + ) : ( + <Trans> + You may appeal these labels if you feel they were placed in + error. + </Trans> + )} </Text> <View style={[a.py_lg, a.gap_md]}> @@ -75,6 +98,7 @@ export function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) { <Label key={`${label.val}-${label.src}`} label={label} + isSelfLabel={label.src === currentAccount?.did} control={props.control} onPressAppeal={label => setAppealingLabel(label)} /> @@ -88,22 +112,14 @@ export function LabelsOnMeDialogInner(props: LabelsOnMeDialogProps) { ) } -export function LabelsOnMeDialog(props: LabelsOnMeDialogProps) { - return ( - <Dialog.Outer control={props.control}> - <Dialog.Handle /> - - <LabelsOnMeDialogInner {...props} /> - </Dialog.Outer> - ) -} - function Label({ label, + isSelfLabel, control, onPressAppeal, }: { label: ComAtprotoLabelDefs.Label + isSelfLabel: boolean control: Dialog.DialogOuterProps['control'] onPressAppeal: (label: ComAtprotoLabelDefs.Label) => void }) { @@ -125,32 +141,42 @@ function Label({ {strings.description} </Text> </View> - <View> - <Button - variant="solid" - color="secondary" - size="small" - label={_(msg`Appeal`)} - onPress={() => onPressAppeal(label)}> - <ButtonText> - <Trans>Appeal</Trans> - </ButtonText> - </Button> - </View> + {!isSelfLabel && ( + <View> + <Button + variant="solid" + color="secondary" + size="small" + label={_(msg`Appeal`)} + onPress={() => onPressAppeal(label)}> + <ButtonText> + <Trans>Appeal</Trans> + </ButtonText> + </Button> + </View> + )} </View> <Divider /> <View style={[a.px_md, a.py_sm, t.atoms.bg_contrast_25]}> <Text style={[t.atoms.text_contrast_medium]}> - <Trans>Source:</Trans>{' '} - <InlineLinkText - to={makeProfileLink( - labeler ? labeler.creator : {did: label.src, handle: ''}, - )} - onPress={() => control.close()}> - {labeler ? sanitizeHandle(labeler.creator.handle, '@') : label.src} - </InlineLinkText> + {isSelfLabel ? ( + <Trans>This label was applied by you</Trans> + ) : ( + <> + <Trans>Source:</Trans>{' '} + <InlineLinkText + to={makeProfileLink( + labeler ? labeler.creator : {did: label.src, handle: ''}, + )} + onPress={() => control.close()}> + {labeler + ? sanitizeHandle(labeler.creator.handle, '@') + : label.src} + </InlineLinkText> + </> + )} </Text> </View> </View> |