From 77178844fd29e2b7b4637557c4068901da0ef4e8 Mon Sep 17 00:00:00 2001 From: Ansh Date: Tue, 15 Aug 2023 13:32:57 -0500 Subject: [APP-798] add key to `ProfileCardPills` render method (#1158) * add key to `ProfileCardPills` render method * More reliable key generation --------- Co-authored-by: Paul Frazee --- src/lib/moderation.ts | 13 +++++++++++++ src/view/com/profile/ProfileCard.tsx | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/moderation.ts b/src/lib/moderation.ts index a90c4dc9c..aadee0e74 100644 --- a/src/lib/moderation.ts +++ b/src/lib/moderation.ts @@ -92,3 +92,16 @@ export function isCauseALabelOnUri( } return cause.label.uri === uri } + +export function getModerationCauseKey(cause: ModerationCause): string { + const source = + cause.source.type === 'labeler' + ? cause.source.labeler.did + : cause.source.type === 'list' + ? cause.source.list.uri + : 'user' + if (cause.type === 'label') { + return `label:${cause.label.val}:${source}` + } + return `${cause.type}:${source}` +} diff --git a/src/view/com/profile/ProfileCard.tsx b/src/view/com/profile/ProfileCard.tsx index ba0c59def..771785ee9 100644 --- a/src/view/com/profile/ProfileCard.tsx +++ b/src/view/com/profile/ProfileCard.tsx @@ -19,6 +19,7 @@ import {makeProfileLink} from 'lib/routes/links' import { describeModerationCause, getProfileModerationCauses, + getModerationCauseKey, } from 'lib/moderation' export const ProfileCard = observer( @@ -131,7 +132,9 @@ function ProfileCardPills({ {causes.map(cause => { const desc = describeModerationCause(cause, 'account') return ( - + {cause?.type === 'label' ? '⚠' : ''} {desc.name} -- cgit 1.4.1