From ac060ab669a9d63f3ca1df7ca6a267cb3ca7408d Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 27 Jun 2025 12:40:13 +0300 Subject: [PATCH] use Link component rather than jank Pressable --- src/view/com/feeds/FeedSourceCard.tsx | 104 +++++++++++++------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/src/view/com/feeds/FeedSourceCard.tsx b/src/view/com/feeds/FeedSourceCard.tsx index bc9e44f224..4b2db8cf63 100644 --- a/src/view/com/feeds/FeedSourceCard.tsx +++ b/src/view/com/feeds/FeedSourceCard.tsx @@ -1,19 +1,13 @@ -import { - Linking, - Pressable, - type StyleProp, - View, - type ViewStyle, -} from 'react-native' +import {type StyleProp, View, type ViewStyle} from 'react-native' import { type $Typed, AppBskyFeedDefs, type AppBskyGraphDefs, AtUri, } from '@atproto/api' -import {Plural, Trans} from '@lingui/macro' +import {msg, Plural, Trans} from '@lingui/macro' +import {useLingui} from '@lingui/react' -import {useNavigationDeduped} from '#/lib/hooks/useNavigationDeduped' import {sanitizeHandle} from '#/lib/strings/handles' import { type FeedSourceInfo, @@ -24,7 +18,7 @@ import { import {FeedLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder' import {UserAvatar} from '#/view/com/util/UserAvatar' import {atoms as a, useTheme} from '#/alf' -import {shouldClickOpenNewTab} from '#/components/Link' +import {Link} from '#/components/Link' import {RichText} from '#/components/RichText' import {Text} from '#/components/Typography' @@ -40,6 +34,7 @@ type FeedSourceCardProps = { pinOnSave?: boolean showMinimalPlaceholder?: boolean hideTopBorder?: boolean + link?: boolean } export function FeedSourceCard({ @@ -78,6 +73,7 @@ export function FeedSourceCardLoaded({ showLikes = false, showMinimalPlaceholder, hideTopBorder, + link = true, }: { feed?: FeedSourceInfo style?: StyleProp @@ -85,9 +81,10 @@ export function FeedSourceCardLoaded({ showLikes?: boolean showMinimalPlaceholder?: boolean hideTopBorder?: boolean + link?: boolean }) { const t = useTheme() - const navigation = useNavigationDeduped() + const {_} = useLingui() /* * LOAD STATE @@ -109,45 +106,8 @@ export function FeedSourceCardLoaded({ /> ) - return ( - { - const shouldOpenInNewTab = shouldClickOpenNewTab(e) - if (feed.type === 'feed') { - if (shouldOpenInNewTab) { - Linking.openURL( - `/profile/${feed.creatorDid}/feed/${new AtUri(feed.uri).rkey}`, - ) - } else { - navigation.push('ProfileFeed', { - name: feed.creatorDid, - rkey: new AtUri(feed.uri).rkey, - }) - } - } else if (feed.type === 'list') { - if (shouldOpenInNewTab) { - Linking.openURL( - `/profile/${feed.creatorDid}/lists/${new AtUri(feed.uri).rkey}`, - ) - } else { - navigation.push('ProfileList', { - name: feed.creatorDid, - rkey: new AtUri(feed.uri).rkey, - }) - } - } - }} - key={feed.uri}> + const inner = ( + <> @@ -170,7 +130,6 @@ export function FeedSourceCardLoaded({ - {showDescription && feed.description ? ( ) : null} - {showLikes && feed.type === 'feed' ? ( ) : null} - + ) + + if (link) { + return ( + + {inner} + + ) + } else { + return ( + + {inner} + + ) + } }