import {View} from 'react-native' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useNavigation, useNavigationState} from '@react-navigation/native' import {getCurrentRoute} from '#/lib/routes/helpers' import {type NavigationProp} from '#/lib/routes/types' import {emitSoftReset} from '#/state/events' import {usePinnedFeedsInfos} from '#/state/queries/feed' import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed' import {atoms as a, useTheme, web} from '#/alf' import {createStaticClick, InlineLinkText} from '#/components/Link' export function DesktopFeeds() { const t = useTheme() const {_} = useLingui() const {data: pinnedFeedInfos, error, isLoading} = usePinnedFeedsInfos() const selectedFeed = useSelectedFeed() const setSelectedFeed = useSetSelectedFeed() const navigation = useNavigation() const route = useNavigationState(state => { if (!state) { return {name: 'Home'} } return getCurrentRoute(state) }) if (isLoading) { return ( {Array(5) .fill(0) .map((_, i) => ( ))} ) } if (error || !pinnedFeedInfos) { return null } return ( {pinnedFeedInfos.map(feedInfo => { const feed = feedInfo.feedDescriptor const current = route.name === 'Home' && feed === selectedFeed return ( { setSelectedFeed(feed) navigation.navigate('Home') if (route.name === 'Home' && feed === selectedFeed) { emitSoftReset() } })} style={[ a.text_md, a.leading_snug, current ? [a.font_bold, t.atoms.text] : [t.atoms.text_contrast_medium], web({ marginHorizontal: 2, width: 'calc(100% - 4px)', }), ]} numberOfLines={1}> {feedInfo.displayName} ) })} {_(msg`More feeds`)} ) }