diff --git a/src/components/moderation/PostAlerts.tsx b/src/components/moderation/PostAlerts.tsx index 3f8f5da32a..218a0ec04c 100644 --- a/src/components/moderation/PostAlerts.tsx +++ b/src/components/moderation/PostAlerts.tsx @@ -31,13 +31,41 @@ export function PostAlerts({ style?: StyleProp additionalCauses?: ModerationCause[] | Pills.AppModerationCause[] }) { + const {currentAccount} = useSession() + if (!modui.alert && !modui.inform && !additionalCauses?.length) { return null } + 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. + */ + const isOwnPost = !!post && post.author.did === currentAccount?.did + const allLabels: ComAtprotoLabelDefs.Label[] = isOwnPost + ? [...(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 + * not be repeated in the "+n" pill. + */ + const shownCauses = [...alerts, ...informs, ...modui.blurs] + const additionalLabels = allLabels.filter(label => + shownCauses.every( + cause => + cause.type !== 'label' || + cause.label.val !== label.val || + cause.label.src !== label.src || + cause.label.uri !== label.uri, + ), + ) + return ( - {modui.alerts.filter(unique).map(cause => ( + {alerts.map(cause => ( ))} - {modui.informs.filter(unique).map(cause => ( + {informs.map(cause => ( ))} - {post?.labels?.length ? ( - + {additionalLabels.length ? ( + ) : null} ) @@ -96,7 +124,7 @@ function AdditionalLabels({ {