Replace PostAlerts size prop with view prop
PostAlerts now takes view: 'expanded' | 'compact' (defaulting to compact) instead of a raw pill size, mapping to lg/sm internally. The additional labels pill only renders in expanded views, so feeds and replies skip the label computation entirely; the thread anchor is the one expanded surface. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -24,31 +24,38 @@ import * as Pills from '#/components/Pills'
|
||||
export function PostAlerts({
|
||||
post,
|
||||
modui,
|
||||
size = 'sm',
|
||||
view = 'compact',
|
||||
style,
|
||||
additionalCauses,
|
||||
}: {
|
||||
post?: AppBskyFeedDefs.PostView
|
||||
modui: ModerationUI
|
||||
size?: Pills.CommonProps['size']
|
||||
/**
|
||||
* Expanded views (e.g. the thread anchor post) render larger pills and
|
||||
* surface the "+n" additional labels pill. Compact views (feeds, replies)
|
||||
* keep the alerts minimal.
|
||||
*/
|
||||
view?: 'expanded' | 'compact'
|
||||
includeMute?: boolean
|
||||
style?: StyleProp<ViewStyle>
|
||||
additionalCauses?: ModerationCause[] | Pills.AppModerationCause[]
|
||||
}) {
|
||||
const {currentAccount} = useSession()
|
||||
const size: Pills.CommonProps['size'] = view === 'expanded' ? 'lg' : 'sm'
|
||||
|
||||
const alerts = modui.alerts.filter(unique)
|
||||
const informs = modui.informs.filter(unique)
|
||||
/*
|
||||
* The "+n" pill surfaces labels for the author to review and appeal, so it
|
||||
* only applies when the viewer is the author. It renders even when no other
|
||||
* moderation is visible, since it may be the author's only entry point to
|
||||
* appeal labels on their content.
|
||||
* only applies when the viewer is the author, and only in expanded views.
|
||||
* It renders even when no other moderation is visible, since it may be the
|
||||
* author's only entry point to appeal labels on their content.
|
||||
*/
|
||||
const isOwnPost = !!post && post.author.did === currentAccount?.did
|
||||
const allLabels: ComAtprotoLabelDefs.Label[] = isOwnPost
|
||||
? [...(post.labels ?? []), ...(post.author.labels ?? [])]
|
||||
: []
|
||||
const allLabels: ComAtprotoLabelDefs.Label[] =
|
||||
isOwnPost && view === 'expanded'
|
||||
? [...(post.labels ?? []), ...(post.author.labels ?? [])]
|
||||
: []
|
||||
/*
|
||||
* Labels that the moderation system already surfaces in this context -
|
||||
* whether as an alert, an inform, or a blur handled by ContentHider - should
|
||||
|
||||
@@ -164,7 +164,6 @@ function DirectChatItem({
|
||||
isWithinLeftPanel ? null : (
|
||||
<PostAlerts
|
||||
modui={moderation.ui('contentList')}
|
||||
size="sm"
|
||||
style={[a.pb_2xs, a.max_w_full, a.overflow_hidden]}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -243,7 +243,6 @@ function MessageInputPostEmbed({
|
||||
post={post}
|
||||
modui={moderation.ui('contentView')}
|
||||
style={a.py_xs}
|
||||
size="sm"
|
||||
/>
|
||||
{rt.text && (
|
||||
<RichText
|
||||
|
||||
@@ -390,7 +390,7 @@ const ThreadItemAnchorInner = memo(function ThreadItemAnchorInner({
|
||||
<PostAlerts
|
||||
post={post}
|
||||
modui={moderation.ui('contentView')}
|
||||
size="lg"
|
||||
view="expanded"
|
||||
includeMute
|
||||
style={[a.pb_sm]}
|
||||
additionalCauses={additionalPostAlerts}
|
||||
|
||||
Reference in New Issue
Block a user