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 patch-version 109 lines 3.0 kB view raw
1import {View} from 'react-native' 2import {msg} from '@lingui/macro' 3import {useLingui} from '@lingui/react' 4import {useNavigation, useNavigationState} from '@react-navigation/native' 5 6import {getCurrentRoute} from '#/lib/routes/helpers' 7import {NavigationProp} from '#/lib/routes/types' 8import {emitSoftReset} from '#/state/events' 9import {usePinnedFeedsInfos} from '#/state/queries/feed' 10import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed' 11import {atoms as a, useTheme, web} from '#/alf' 12import {createStaticClick, InlineLinkText} from '#/components/Link' 13 14export function DesktopFeeds() { 15 const t = useTheme() 16 const {_} = useLingui() 17 const {data: pinnedFeedInfos, error, isLoading} = usePinnedFeedsInfos() 18 const selectedFeed = useSelectedFeed() 19 const setSelectedFeed = useSetSelectedFeed() 20 const navigation = useNavigation<NavigationProp>() 21 const route = useNavigationState(state => { 22 if (!state) { 23 return {name: 'Home'} 24 } 25 return getCurrentRoute(state) 26 }) 27 28 if (isLoading) { 29 return ( 30 <View 31 style={[ 32 { 33 gap: 12, 34 }, 35 ]}> 36 {Array(5) 37 .fill(0) 38 .map((_, i) => ( 39 <View 40 key={i} 41 style={[ 42 a.rounded_sm, 43 t.atoms.bg_contrast_25, 44 { 45 height: 16, 46 width: i % 2 === 0 ? '60%' : '80%', 47 }, 48 ]} 49 /> 50 ))} 51 </View> 52 ) 53 } 54 55 if (error || !pinnedFeedInfos) { 56 return null 57 } 58 59 return ( 60 <View 61 style={[ 62 web({ 63 gap: 10, 64 /* 65 * Small padding prevents overflow prior to actually overflowing the 66 * height of the screen with lots of feeds. 67 */ 68 paddingVertical: 2, 69 overflowY: 'auto', 70 }), 71 ]}> 72 {pinnedFeedInfos.map(feedInfo => { 73 const feed = feedInfo.feedDescriptor 74 const current = route.name === 'Home' && feed === selectedFeed 75 76 return ( 77 <InlineLinkText 78 key={feedInfo.uri} 79 label={feedInfo.displayName} 80 {...createStaticClick(() => { 81 setSelectedFeed(feed) 82 navigation.navigate('Home') 83 if (route.name === 'Home' && feed === selectedFeed) { 84 emitSoftReset() 85 } 86 })} 87 style={[ 88 a.text_md, 89 a.leading_snug, 90 current 91 ? [a.font_bold, t.atoms.text] 92 : [t.atoms.text_contrast_medium], 93 ]} 94 numberOfLines={1}> 95 {feedInfo.displayName} 96 </InlineLinkText> 97 ) 98 })} 99 100 <InlineLinkText 101 to="/feeds" 102 label={_(msg`More feeds`)} 103 style={[a.text_md, a.leading_snug]} 104 numberOfLines={1}> 105 {_(msg`More feeds`)} 106 </InlineLinkText> 107 </View> 108 ) 109}