Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102import {type StyleProp, View, type ViewStyle} from 'react-native'import {type AppBskyFeedDefs, type ComAtprotoLabelDefs} from '@atproto/api'import {msg} from '@lingui/core/macro'import {useLingui} from '@lingui/react'import {Plural, Trans} from '@lingui/react/macro'
import {useSession} from '#/state/session'import {atoms as a} from '#/alf'import { Button, ButtonIcon, type ButtonSize, ButtonText,} from '#/components/Button'import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'import { LabelsOnMeDialog, useLabelsOnMeDialogControl,} from '#/components/moderation/LabelsOnMeDialog'
export function LabelsOnMe({ type, labels, size, style,}: { type: 'account' | 'content' labels: ComAtprotoLabelDefs.Label[] | undefined size?: ButtonSize style?: StyleProp<ViewStyle>}) { const {_} = useLingui() const {currentAccount} = useSession() 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 ( <View style={[a.flex_row, style]}> <LabelsOnMeDialog control={control} labels={labels} type={type} />
<Button variant="solid" color="secondary" size={size || 'small'} label={_(msg`View information about these labels`)} onPress={() => { control.open() }}> <ButtonIcon position="left" icon={CircleInfo} /> <ButtonText style={[a.leading_snug]}> {type === 'account' ? ( <Trans> <Plural value={labels.length} one="# label has" other="# labels have" />{' '} been placed on this account </Trans> ) : ( <Trans> <Plural value={labels.length} one="# label has" other="# labels have" />{' '} been placed on this content </Trans> )} </ButtonText> </Button> </View> )}
export function LabelsOnMyPost({ post, style,}: { post: AppBskyFeedDefs.PostView style?: StyleProp<ViewStyle>}) { const {currentAccount} = useSession() if (post.author.did !== currentAccount?.did) { return null } return ( <LabelsOnMe type="content" labels={post.labels} size="tiny" style={style} /> )}