Improve consistency of display name blurring

This commit is contained in:
Paul Frazee
2024-03-02 12:03:21 -08:00
parent bde59a6de5
commit d1ffe94b00
8 changed files with 19 additions and 7 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ export function sanitizeDisplayName(
moderation?: ModerationUI, moderation?: ModerationUI,
): string { ): string {
if (moderation?.blur) { if (moderation?.blur) {
return `⚠ Display name hidden` return ''
} }
if (typeof str === 'string') { if (typeof str === 'string') {
return str.replace(CHECK_MARKS_RE, '').replace(CONTROL_CHARS_RE, '').trim() return str.replace(CHECK_MARKS_RE, '').replace(CONTROL_CHARS_RE, '').trim()
@@ -83,6 +83,7 @@ let ProfileHeaderStandard = ({
_( _(
msg`Following ${sanitizeDisplayName( msg`Following ${sanitizeDisplayName(
profile.displayName || profile.handle, profile.displayName || profile.handle,
moderation.ui('displayName'),
)}`, )}`,
), ),
) )
@@ -104,6 +105,7 @@ let ProfileHeaderStandard = ({
_( _(
msg`No longer following ${sanitizeDisplayName( msg`No longer following ${sanitizeDisplayName(
profile.displayName || profile.handle, profile.displayName || profile.handle,
moderation.ui('displayName'),
)}`, )}`,
), ),
) )
@@ -268,6 +268,7 @@ let PostThreadItemLoaded = ({
{sanitizeDisplayName( {sanitizeDisplayName(
post.author.displayName || post.author.displayName ||
sanitizeHandle(post.author.handle), sanitizeHandle(post.author.handle),
moderation.ui('displayName'),
)} )}
</Text> </Text>
</Link> </Link>
@@ -469,6 +470,7 @@ let PostThreadItemLoaded = ({
}> }>
<PostMeta <PostMeta
author={post.author} author={post.author}
moderation={moderation}
authorHasWarning={!!post.author.labels?.length} authorHasWarning={!!post.author.labels?.length}
timestamp={post.indexedAt} timestamp={post.indexedAt}
postHref={postHref} postHref={postHref}
+1
View File
@@ -149,6 +149,7 @@ function PostInner({
<View style={styles.layoutContent}> <View style={styles.layoutContent}>
<PostMeta <PostMeta
author={post.author} author={post.author}
moderation={moderation}
authorHasWarning={!!post.author.labels?.length} authorHasWarning={!!post.author.labels?.length}
timestamp={post.indexedAt} timestamp={post.indexedAt}
postHref={itemHref} postHref={itemHref}
+2
View File
@@ -231,6 +231,7 @@ let FeedItemInner = ({
numberOfLines={1} numberOfLines={1}
text={sanitizeDisplayName( text={sanitizeDisplayName(
reason.by.displayName || sanitizeHandle(reason.by.handle), reason.by.displayName || sanitizeHandle(reason.by.handle),
moderation.ui('displayName'),
)} )}
href={makeProfileLink(reason.by)} href={makeProfileLink(reason.by)}
/> />
@@ -266,6 +267,7 @@ let FeedItemInner = ({
<View style={styles.layoutContent}> <View style={styles.layoutContent}>
<PostMeta <PostMeta
author={post.author} author={post.author}
moderation={moderation}
authorHasWarning={!!post.author.labels?.length} authorHasWarning={!!post.author.labels?.length}
timestamp={post.indexedAt} timestamp={post.indexedAt}
postHref={href} postHref={href}
+7 -2
View File
@@ -11,7 +11,7 @@ import {sanitizeHandle} from 'lib/strings/handles'
import {isAndroid, isWeb} from 'platform/detection' import {isAndroid, isWeb} from 'platform/detection'
import {TimeElapsed} from './TimeElapsed' import {TimeElapsed} from './TimeElapsed'
import {makeProfileLink} from 'lib/routes/links' import {makeProfileLink} from 'lib/routes/links'
import {ModerationUI} from '@atproto/api' import {ModerationDecision, ModerationUI} from '@atproto/api'
import {usePrefetchProfileQuery} from '#/state/queries/profile' import {usePrefetchProfileQuery} from '#/state/queries/profile'
interface PostMetaOpts { interface PostMetaOpts {
@@ -21,6 +21,7 @@ interface PostMetaOpts {
handle: string handle: string
displayName?: string | undefined displayName?: string | undefined
} }
moderation: ModerationDecision | undefined
authorHasWarning: boolean authorHasWarning: boolean
postHref: string postHref: string
timestamp: string timestamp: string
@@ -57,7 +58,11 @@ let PostMeta = (opts: PostMetaOpts): React.ReactNode => {
lineHeight={1.2} lineHeight={1.2}
text={ text={
<> <>
{sanitizeDisplayName(displayName)}&nbsp; {sanitizeDisplayName(
displayName,
opts.moderation?.ui('displayName'),
)}
&nbsp;
<Text <Text
type="md" type="md"
numberOfLines={1} numberOfLines={1}
@@ -144,6 +144,7 @@ export function QuoteEmbed({
<View pointerEvents="none"> <View pointerEvents="none">
<PostMeta <PostMeta
author={quote.author} author={quote.author}
moderation={moderation}
showAvatar showAvatar
authorHasWarning={false} authorHasWarning={false}
postHref={itemHref} postHref={itemHref}
+3 -4
View File
@@ -31,7 +31,6 @@ import {H1, H3, P, Text} from '#/components/Typography'
import {useLabelStrings} from '#/lib/moderation/useLabelStrings' import {useLabelStrings} from '#/lib/moderation/useLabelStrings'
import * as Toggle from '#/components/forms/Toggle' import * as Toggle from '#/components/forms/Toggle'
import * as ToggleButton from '#/components/forms/ToggleButton' import * as ToggleButton from '#/components/forms/ToggleButton'
import * as TextField from '#/components/forms/TextField'
import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {Button, ButtonIcon, ButtonText} from '#/components/Button'
import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check'
import { import {
@@ -62,7 +61,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
const [visibility, setVisiblity] = React.useState<string[]>(['hide']) const [visibility, setVisiblity] = React.useState<string[]>(['hide'])
const [customLabelDef, setCustomLabelDef] = const [customLabelDef, setCustomLabelDef] =
React.useState<ComAtprotoLabelDefs.LabelValueDefinition>({ React.useState<ComAtprotoLabelDefs.LabelValueDefinition>({
identifier: 'x-custom', identifier: 'custom',
blurs: 'content', blurs: 'content',
severity: 'alert', severity: 'alert',
locales: [ locales: [
@@ -319,7 +318,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
) )
})} })}
<Toggle.Item <Toggle.Item
name="x-custom" name="custom"
label="Custom label" label="Custom label"
disabled={isSelfLabel} disabled={isSelfLabel}
style={isSelfLabel ? {opacity: 0.5} : undefined}> style={isSelfLabel ? {opacity: 0.5} : undefined}>
@@ -329,7 +328,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
</View> </View>
</Toggle.Group> </Toggle.Group>
{label[0] === 'x-custom' ? ( {label[0] === 'custom' ? (
<CustomLabelForm <CustomLabelForm
def={customLabelDef} def={customLabelDef}
setDef={setCustomLabelDef} setDef={setCustomLabelDef}