Render additional labels pill standalone with spelled-out text
Move the early return below the additional labels computation so the pill renders on the author's own post even when no other moderation is visible - it may be their only entry point to appeal labels on their content. When no other pills precede it, spell out "n labels applied" instead of the "+n" continuation syntax. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,15 +33,13 @@ export function PostAlerts({
|
|||||||
}) {
|
}) {
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
|
||||||
if (!modui.alert && !modui.inform && !additionalCauses?.length) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
const alerts = modui.alerts.filter(unique)
|
const alerts = modui.alerts.filter(unique)
|
||||||
const informs = modui.informs.filter(unique)
|
const informs = modui.informs.filter(unique)
|
||||||
/*
|
/*
|
||||||
* The "+n" pill surfaces labels for the author to review and appeal, so it
|
* The "+n" pill surfaces labels for the author to review and appeal, so it
|
||||||
* only applies when the viewer is the author.
|
* 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.
|
||||||
*/
|
*/
|
||||||
const isOwnPost = !!post && post.author.did === currentAccount?.did
|
const isOwnPost = !!post && post.author.did === currentAccount?.did
|
||||||
const allLabels: ComAtprotoLabelDefs.Label[] = isOwnPost
|
const allLabels: ComAtprotoLabelDefs.Label[] = isOwnPost
|
||||||
@@ -67,6 +65,15 @@ export function PostAlerts({
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (
|
||||||
|
!modui.alert &&
|
||||||
|
!modui.inform &&
|
||||||
|
!additionalCauses?.length &&
|
||||||
|
!additionalLabels.length
|
||||||
|
) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Pills.Row size={size} style={[size === 'sm' && {marginLeft: -3}, style]}>
|
<Pills.Row size={size} style={[size === 'sm' && {marginLeft: -3}, style]}>
|
||||||
{alerts.map(cause => (
|
{alerts.map(cause => (
|
||||||
@@ -94,7 +101,15 @@ export function PostAlerts({
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{additionalLabels.length ? (
|
{additionalLabels.length ? (
|
||||||
<AdditionalLabels labels={additionalLabels} size={size} />
|
<AdditionalLabels
|
||||||
|
labels={additionalLabels}
|
||||||
|
size={size}
|
||||||
|
hasPrecedingPills={
|
||||||
|
alerts.length > 0 ||
|
||||||
|
informs.length > 0 ||
|
||||||
|
(additionalCauses?.length ?? 0) > 0
|
||||||
|
}
|
||||||
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</Pills.Row>
|
</Pills.Row>
|
||||||
)
|
)
|
||||||
@@ -103,9 +118,15 @@ export function PostAlerts({
|
|||||||
function AdditionalLabels({
|
function AdditionalLabels({
|
||||||
labels,
|
labels,
|
||||||
size,
|
size,
|
||||||
|
hasPrecedingPills,
|
||||||
}: {
|
}: {
|
||||||
labels: ComAtprotoLabelDefs.Label[]
|
labels: ComAtprotoLabelDefs.Label[]
|
||||||
size?: Pills.CommonProps['size']
|
size?: Pills.CommonProps['size']
|
||||||
|
/**
|
||||||
|
* The compact "+n" syntax only makes sense as a continuation of other
|
||||||
|
* pills. When this pill stands alone, spell it out.
|
||||||
|
*/
|
||||||
|
hasPrecedingPills: boolean
|
||||||
}) {
|
}) {
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const control = useLabelsOnMeDialogControl()
|
const control = useLabelsOnMeDialogControl()
|
||||||
@@ -115,7 +136,14 @@ function AdditionalLabels({
|
|||||||
<LabelsOnMeDialog control={control} labels={labels} type="content" />
|
<LabelsOnMeDialog control={control} labels={labels} type="content" />
|
||||||
|
|
||||||
<Pills.LabelBase
|
<Pills.LabelBase
|
||||||
label={l`+${plural(labels.length, {one: '#', other: '#'})}`}
|
label={
|
||||||
|
hasPrecedingPills
|
||||||
|
? l`+${labels.length}`
|
||||||
|
: l`${plural(labels.length, {
|
||||||
|
one: '# label applied',
|
||||||
|
other: '# labels applied',
|
||||||
|
})}`
|
||||||
|
}
|
||||||
size={size}
|
size={size}
|
||||||
noBg={size === 'sm'}
|
noBg={size === 'sm'}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user