mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

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

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