* First pass moving to the new labeling sdk (it compiles) * Correct behaviors around interpreting label moderation * Improve moderation state rendering * Improve hiders and alerts * Improve handling of mutes * Improve profile warnings * Add profile blurring to profile header * Add blocks to test cases * Render labels on profile cards, do not filter * Filter profiles from suggestions using moderation * Apply profile blurring to ProfileCard * Handle blocked and deleted quote posts * Temporarily translate content filtering settings to new labels * Fix types * Tune ContentHider & PostHider click targets * Put a warning on profilecard label pills * Fix screenhider learnmore link on mobile * Enforce no-override on user avatar * Dont enumerate profile blur-media labels in alerts * Fixes to muted posts (esp quotes of muted users) * Fixes to account/profile warnings * Bump @atproto/api@0.5.0 * Bump @atproto/api@0.5.1 * Fix tests * 1.43 * Remove log * Bump @atproto/api@0.5.2
36 lines
774 B
TypeScript
36 lines
774 B
TypeScript
import {ModerationUI} from '@atproto/api'
|
|
import {describeModerationCause} from '../moderation'
|
|
|
|
// \u2705 = ✅
|
|
// \u2713 = ✓
|
|
// \u2714 = ✔
|
|
// \u2611 = ☑
|
|
const CHECK_MARKS_RE = /[\u2705\u2713\u2714\u2611]/gu
|
|
|
|
export function sanitizeDisplayName(
|
|
str: string,
|
|
moderation?: ModerationUI,
|
|
): string {
|
|
if (moderation?.blur) {
|
|
return `⚠${describeModerationCause(moderation.cause, 'account').name}`
|
|
}
|
|
if (typeof str === 'string') {
|
|
return str.replace(CHECK_MARKS_RE, '').trim()
|
|
}
|
|
return ''
|
|
}
|
|
|
|
export function combinedDisplayName({
|
|
handle,
|
|
displayName,
|
|
}: {
|
|
handle?: string
|
|
displayName?: string
|
|
}): string {
|
|
if (!handle) {
|
|
return ''
|
|
}
|
|
return displayName
|
|
? `${sanitizeDisplayName(displayName)} (@${handle})`
|
|
: `@${handle}`
|
|
}
|