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