From 39147619be0b537532e15d00880d85472efbdb6f Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 9 Jul 2026 14:03:05 -0500 Subject: [PATCH] POC: +n labels --- src/components/Pills.tsx | 77 +++++++++++++++++++ src/components/moderation/PostAlerts.tsx | 61 ++++++++++++++- .../components/ThreadItemAnchor.tsx | 1 + 3 files changed, 137 insertions(+), 2 deletions(-) diff --git a/src/components/Pills.tsx b/src/components/Pills.tsx index 37e940d206..d59aba1955 100644 --- a/src/components/Pills.tsx +++ b/src/components/Pills.tsx @@ -151,6 +151,83 @@ export function Label({ ) } +export type LabelBaseProps = { + label: string + onPress: () => void + noBg?: boolean +} & CommonProps + +export function LabelBase({label, onPress, size = 'sm', noBg}: LabelBaseProps) { + const t = useTheme() + + const {outer, text} = useMemo(() => { + switch (size) { + case 'lg': { + return { + outer: [ + t.atoms.bg_contrast_25, + { + gap: 5, + paddingHorizontal: 5, + paddingVertical: 5, + }, + ], + text: [a.text_sm], + } + } + case 'sm': + default: { + return { + outer: [ + !noBg && t.atoms.bg_contrast_25, + { + gap: 3, + paddingHorizontal: 3, + paddingVertical: 3, + }, + ], + text: [a.text_xs], + } + } + } + }, [t, size, noBg]) + + return ( + <> + + + ) +} + export function FollowsYou({size = 'sm'}: CommonProps) { const t = useTheme() diff --git a/src/components/moderation/PostAlerts.tsx b/src/components/moderation/PostAlerts.tsx index 7a9c38cc61..3f8f5da32a 100644 --- a/src/components/moderation/PostAlerts.tsx +++ b/src/components/moderation/PostAlerts.tsx @@ -1,15 +1,30 @@ -import {type StyleProp, type ViewStyle} from 'react-native' -import {type ModerationCause, type ModerationUI} from '@atproto/api' +import {type StyleProp, View, type ViewStyle} from 'react-native' +import { + type AppBskyFeedDefs, + type ComAtprotoLabelDefs, + type ModerationCause, + type ModerationUI, +} from '@atproto/api' +import {plural} from '@lingui/core/macro' +import {useLingui} from '@lingui/react/macro' import {getModerationCauseKey, unique} from '#/lib/moderation' +import {useSession} from '#/state/session' +import {atoms as a} from '#/alf' +import { + LabelsOnMeDialog, + useLabelsOnMeDialogControl, +} from '#/components/moderation/LabelsOnMeDialog' import * as Pills from '#/components/Pills' export function PostAlerts({ + post, modui, size = 'sm', style, additionalCauses, }: { + post?: AppBskyFeedDefs.PostView modui: ModerationUI size?: Pills.CommonProps['size'] includeMute?: boolean @@ -46,6 +61,48 @@ export function PostAlerts({ noBg={size === 'sm'} /> ))} + {post?.labels?.length ? ( + + ) : null} ) } + +function AdditionalLabels({ + labels, + size, +}: { + labels: ComAtprotoLabelDefs.Label[] | undefined + size?: Pills.CommonProps['size'] +}) { + const {t: l} = useLingui() + const {currentAccount} = useSession() + const control = useLabelsOnMeDialogControl() + + if (!labels || !currentAccount) { + return null + } + labels = labels.filter( + l => + !l.val.startsWith('!') && + !(l.val === 'bot' && l.src === currentAccount.did), + ) + if (!labels.length) { + return null + } + + return ( + + + + { + control.open() + }} + /> + + ) +} diff --git a/src/screens/PostThread/components/ThreadItemAnchor.tsx b/src/screens/PostThread/components/ThreadItemAnchor.tsx index 9439adc8e3..7626ab61fb 100644 --- a/src/screens/PostThread/components/ThreadItemAnchor.tsx +++ b/src/screens/PostThread/components/ThreadItemAnchor.tsx @@ -388,6 +388,7 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({ ignoreMute childContainerStyle={[a.pt_sm]}>