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