Hoist appealable-label filtering into PostAlerts

Apply the same system-label and self bot-label exclusions as
LabelsOnMe when computing the additional labels list, and do it in
the parent so the render gate is reliable. AdditionalLabels becomes
purely presentational.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Eric Bailey
2026-07-09 17:57:40 -05:00
parent 33ef6882e9
commit e692e45982
+14 -23
View File
@@ -50,17 +50,21 @@ export function PostAlerts({
/* /*
* Labels that the moderation system already surfaces in this context - * Labels that the moderation system already surfaces in this context -
* whether as an alert, an inform, or a blur handled by ContentHider - should * whether as an alert, an inform, or a blur handled by ContentHider - should
* not be repeated in the "+n" pill. * not be repeated in the "+n" pill. System labels and the author's own
* "bot" self-label are excluded the same way LabelsOnMe excludes them.
*/ */
const shownCauses = [...alerts, ...informs, ...modui.blurs] const shownCauses = [...alerts, ...informs, ...modui.blurs]
const additionalLabels = allLabels.filter(label => const additionalLabels = allLabels.filter(
shownCauses.every( label =>
cause => !label.val.startsWith('!') &&
cause.type !== 'label' || !(label.val === 'bot' && label.src === currentAccount?.did) &&
cause.label.val !== label.val || shownCauses.every(
cause.label.src !== label.src || cause =>
cause.label.uri !== label.uri, cause.type !== 'label' ||
), cause.label.val !== label.val ||
cause.label.src !== label.src ||
cause.label.uri !== label.uri,
),
) )
return ( return (
@@ -100,25 +104,12 @@ function AdditionalLabels({
labels, labels,
size, size,
}: { }: {
labels: ComAtprotoLabelDefs.Label[] | undefined labels: ComAtprotoLabelDefs.Label[]
size?: Pills.CommonProps['size'] size?: Pills.CommonProps['size']
}) { }) {
const {t: l} = useLingui() const {t: l} = useLingui()
const {currentAccount} = useSession()
const control = useLabelsOnMeDialogControl() 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 ( return (
<View style={[a.flex_row]}> <View style={[a.flex_row]}>
<LabelsOnMeDialog control={control} labels={labels} type="content" /> <LabelsOnMeDialog control={control} labels={labels} type="content" />