Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 101 lines 2.6 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( 40 l => 41 !l.val.startsWith('!') && 42 !(l.val === 'bot' && l.src === currentAccount.did), 43 ) 44 if (!labels.length) { 45 return null 46 } 47 48 return ( 49 <View style={[a.flex_row, style]}> 50 <LabelsOnMeDialog control={control} labels={labels} type={type} /> 51 52 <Button 53 variant="solid" 54 color="secondary" 55 size={size || 'small'} 56 label={_(msg`View information about these labels`)} 57 onPress={() => { 58 control.open() 59 }}> 60 <ButtonIcon position="left" icon={CircleInfo} /> 61 <ButtonText style={[a.leading_snug]}> 62 {type === 'account' ? ( 63 <Trans> 64 <Plural 65 value={labels.length} 66 one="# label has" 67 other="# labels have" 68 />{' '} 69 been placed on this account 70 </Trans> 71 ) : ( 72 <Trans> 73 <Plural 74 value={labels.length} 75 one="# label has" 76 other="# labels have" 77 />{' '} 78 been placed on this content 79 </Trans> 80 )} 81 </ButtonText> 82 </Button> 83 </View> 84 ) 85} 86 87export function LabelsOnMyPost({ 88 post, 89 style, 90}: { 91 post: AppBskyFeedDefs.PostView 92 style?: StyleProp<ViewStyle> 93}) { 94 const {currentAccount} = useSession() 95 if (post.author.did !== currentAccount?.did) { 96 return null 97 } 98 return ( 99 <LabelsOnMe type="content" labels={post.labels} size="tiny" style={style} /> 100 ) 101}