diff options
author | Samuel Newman <mozzius@protonmail.com> | 2025-02-24 14:17:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-24 14:17:59 -0800 |
commit | 6254cf020aa14ead39438f90cd72f915a8639c61 (patch) | |
tree | a05d87dbf65c5708da74b460a9d30ccabdfd60f7 | |
parent | 61a14043e51475b64c5c505dd10d81a0165bb3f2 (diff) | |
download | voidsky-6254cf020aa14ead39438f90cd72f915a8639c61.tar.zst |
Dedupe profile labels (#7833)
* dedupe labels * apply to postalerts
-rw-r--r-- | src/components/moderation/PostAlerts.tsx | 6 | ||||
-rw-r--r-- | src/components/moderation/ProfileHeaderAlerts.tsx | 6 | ||||
-rw-r--r-- | src/lib/moderation.ts | 12 | ||||
-rw-r--r-- | src/screens/Profile/Header/Shell.tsx | 1 |
4 files changed, 18 insertions, 7 deletions
diff --git a/src/components/moderation/PostAlerts.tsx b/src/components/moderation/PostAlerts.tsx index a68a650d6..e5d30da15 100644 --- a/src/components/moderation/PostAlerts.tsx +++ b/src/components/moderation/PostAlerts.tsx @@ -1,7 +1,7 @@ import {StyleProp, ViewStyle} from 'react-native' import {ModerationCause, ModerationUI} from '@atproto/api' -import {getModerationCauseKey} from '#/lib/moderation' +import {getModerationCauseKey, unique} from '#/lib/moderation' import * as Pills from '#/components/Pills' export function PostAlerts({ @@ -22,7 +22,7 @@ export function PostAlerts({ return ( <Pills.Row size={size} style={[size === 'sm' && {marginLeft: -3}, style]}> - {modui.alerts.map(cause => ( + {modui.alerts.filter(unique).map(cause => ( <Pills.Label key={getModerationCauseKey(cause)} cause={cause} @@ -30,7 +30,7 @@ export function PostAlerts({ noBg={size === 'sm'} /> ))} - {modui.informs.map(cause => ( + {modui.informs.filter(unique).map(cause => ( <Pills.Label key={getModerationCauseKey(cause)} cause={cause} diff --git a/src/components/moderation/ProfileHeaderAlerts.tsx b/src/components/moderation/ProfileHeaderAlerts.tsx index 4ac561fd9..9aed1f13d 100644 --- a/src/components/moderation/ProfileHeaderAlerts.tsx +++ b/src/components/moderation/ProfileHeaderAlerts.tsx @@ -1,7 +1,7 @@ import {StyleProp, ViewStyle} from 'react-native' import {ModerationDecision} from '@atproto/api' -import {getModerationCauseKey} from '#/lib/moderation' +import {getModerationCauseKey, unique} from '#/lib/moderation' import * as Pills from '#/components/Pills' export function ProfileHeaderAlerts({ @@ -17,14 +17,14 @@ export function ProfileHeaderAlerts({ return ( <Pills.Row size="lg"> - {modui.alerts.map(cause => ( + {modui.alerts.filter(unique).map(cause => ( <Pills.Label size="lg" key={getModerationCauseKey(cause)} cause={cause} /> ))} - {modui.informs.map(cause => ( + {modui.informs.filter(unique).map(cause => ( <Pills.Label size="lg" key={getModerationCauseKey(cause)} diff --git a/src/lib/moderation.ts b/src/lib/moderation.ts index be503f4c7..cda7d3fa8 100644 --- a/src/lib/moderation.ts +++ b/src/lib/moderation.ts @@ -137,3 +137,15 @@ export function useLabelSubject({label}: {label: ComAtprotoLabelDefs.Label}): { } }, [label]) } + +export function unique( + value: ModerationCause, + index: number, + array: ModerationCause[], +) { + return ( + array.findIndex( + item => getModerationCauseKey(item) === getModerationCauseKey(value), + ) === index + ) +} diff --git a/src/screens/Profile/Header/Shell.tsx b/src/screens/Profile/Header/Shell.tsx index dedbfd201..a3efdedf5 100644 --- a/src/screens/Profile/Header/Shell.tsx +++ b/src/screens/Profile/Header/Shell.tsx @@ -199,7 +199,6 @@ const styles = StyleSheet.create({ height: 30, overflow: 'hidden', borderRadius: 15, - // @ts-ignore web only cursor: 'pointer', backgroundColor: 'rgba(0, 0, 0, 0.5)', alignItems: 'center', |