Bluesky app fork with some witchin' additions 馃挮 witchsky.app
bluesky fork client
at main 97 lines 2.5 kB view raw
1import {type StyleProp, View, type ViewStyle} from 'react-native' 2import {type AppBskyFeedDefs, type ComAtprotoLabelDefs} from '@atproto/api' 3import {msg} from '@lingui/core/macro' 4import {useLingui} from '@lingui/react' 5import {Plural, Trans} from '@lingui/react/macro' 6 7import {useSession} from '#/state/session' 8import {atoms as a} from '#/alf' 9import { 10 Button, 11 ButtonIcon, 12 type ButtonSize, 13 ButtonText, 14} from '#/components/Button' 15import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo' 16import { 17 LabelsOnMeDialog, 18 useLabelsOnMeDialogControl, 19} from '#/components/moderation/LabelsOnMeDialog' 20 21export function LabelsOnMe({ 22 type, 23 labels, 24 size, 25 style, 26}: { 27 type: 'account' | 'content' 28 labels: ComAtprotoLabelDefs.Label[] | undefined 29 size?: ButtonSize 30 style?: StyleProp<ViewStyle> 31}) { 32 const {_} = useLingui() 33 const {currentAccount} = useSession() 34 const control = useLabelsOnMeDialogControl() 35 36 if (!labels || !currentAccount) { 37 return null 38 } 39 labels = labels.filter(l => !l.val.startsWith('!')) 40 if (!labels.length) { 41 return null 42 } 43 44 return ( 45 <View style={[a.flex_row, style]}> 46 <LabelsOnMeDialog control={control} labels={labels} type={type} /> 47 48 <Button 49 variant="solid" 50 color="secondary" 51 size={size || 'small'} 52 label={_(msg`View information about these labels`)} 53 onPress={() => { 54 control.open() 55 }}> 56 <ButtonIcon position="left" icon={CircleInfo} /> 57 <ButtonText style={[a.leading_snug]}> 58 {type === 'account' ? ( 59 <Trans> 60 <Plural 61 value={labels.length} 62 one="# label has" 63 other="# labels have" 64 />{' '} 65 been placed on this account 66 </Trans> 67 ) : ( 68 <Trans> 69 <Plural 70 value={labels.length} 71 one="# label has" 72 other="# labels have" 73 />{' '} 74 been placed on this content 75 </Trans> 76 )} 77 </ButtonText> 78 </Button> 79 </View> 80 ) 81} 82 83export function LabelsOnMyPost({ 84 post, 85 style, 86}: { 87 post: AppBskyFeedDefs.PostView 88 style?: StyleProp<ViewStyle> 89}) { 90 const {currentAccount} = useSession() 91 if (post.author.did !== currentAccount?.did) { 92 return null 93 } 94 return ( 95 <LabelsOnMe type="content" labels={post.labels} size="tiny" style={style} /> 96 ) 97}