Handle self labels

This commit is contained in:
Eric Bailey
2024-03-13 15:15:42 -05:00
parent 6d0ac69a23
commit 65b2b451a7
3 changed files with 31 additions and 20 deletions
+14 -12
View File
@@ -125,7 +125,7 @@ export function ContentHider({
label={_(
msg`Learn more about the moderation applied to this content.`,
)}
style={[a.pt_xs]}>
style={[a.pt_sm]}>
{state => (
<Text
style={[
@@ -136,17 +136,19 @@ export function ContentHider({
t.atoms.text_contrast_medium,
a.text_left,
]}>
<Trans>
Labeled by {sanitizeDisplayName(desc.source!)}.{' '}
<Text
style={[
{color: t.palette.primary_500},
a.text_sm,
state.hovered && [web({textDecoration: 'underline'})],
]}>
Learn more.
</Text>
</Trans>
{desc.sourceType === 'user' ? (
<Trans>Labeled by the author.</Trans>
) : (
<Trans>Labeled by {sanitizeDisplayName(desc.source!)}.</Trans>
)}{' '}
<Text
style={[
{color: t.palette.primary_500},
a.text_sm,
state.hovered && [web({textDecoration: 'underline'})],
]}>
<Trans>Learn more.</Trans>
</Text>
</Text>
)}
</Button>
@@ -124,12 +124,16 @@ function ModerationDetailsDialogInner({
<Text style={[t.atoms.text, a.text_md, a.leading_snug, a.mt_lg]}>
<Trans>
This label was applied by{' '}
<InlineLink
to={makeProfileLink({did: modcause.label.src, handle: ''})}
onPress={() => control.close()}
style={a.text_md}>
@{desc.source}
</InlineLink>
{modcause.source.type === 'user' ? (
'the author'
) : (
<InlineLink
to={makeProfileLink({did: modcause.label.src, handle: ''})}
onPress={() => control.close()}
style={a.text_md}>
@{desc.source}
</InlineLink>
)}
.
</Trans>
</Text>
@@ -1,4 +1,4 @@
import {ModerationCause} from '@atproto/api'
import {ModerationCause, ModerationCauseSource} from '@atproto/api'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {useGlobalLabelStrings} from './useGlobalLabelStrings'
@@ -16,6 +16,7 @@ export interface ModerationCauseDescription {
name: string
description: string
source?: string
sourceType?: ModerationCauseSource['type']
}
export function useModerationCauseDescription(
@@ -114,7 +115,11 @@ export function useModerationCauseDescription(
: CircleInfo,
name: strings.name,
description: strings.description,
source: labeler?.creator.displayName || labeler?.creator.handle,
source:
labeler?.creator.displayName ||
(labeler?.creator.handle ? '@' + labeler?.creator.handle : undefined) ||
cause.label.src,
sourceType: cause.source.type,
}
}
// should never happen