diff --git a/src/features/profileLinks/components/LinkPreviewSheet.tsx b/src/features/profileLinks/components/LinkPreviewSheet.tsx index d1511c7b1..4e46cf8d2 100644 --- a/src/features/profileLinks/components/LinkPreviewSheet.tsx +++ b/src/features/profileLinks/components/LinkPreviewSheet.tsx @@ -1,4 +1,4 @@ -import {View} from 'react-native' +import {type GestureResponderEvent, View} from 'react-native' import {setStringAsync} from 'expo-clipboard' import {Trans, useLingui} from '@lingui/react/macro' @@ -24,7 +24,7 @@ export function LinkPreviewSheet({ }: { control: Dialog.DialogControlProps link: ProfileLink | null - onOpen: (link: ProfileLink) => void + onOpen: (link: ProfileLink, e: GestureResponderEvent) => void /** Runs after the sheet closes. Leave unset to hide reporting. */ onReport?: () => void }) { @@ -48,7 +48,7 @@ function LinkPreviewSheetInner({ onReport, }: { link: ProfileLink - onOpen: (link: ProfileLink) => void + onOpen: (link: ProfileLink, e: GestureResponderEvent) => void onReport?: () => void }) { const control = Dialog.useDialogContext() @@ -83,7 +83,7 @@ function LinkPreviewSheetInner({ testID="profileLinkPreviewOpenBtn" label={l`Open link`} accessibilityHint={l`Opens ${link.url} outside Bluesky`} - onPress={() => control.close(() => onOpen(link))} + onPress={e => control.close(() => onOpen(link, e))} size="large" color="primary"> diff --git a/src/features/profileLinks/components/ProfileLinks.tsx b/src/features/profileLinks/components/ProfileLinks.tsx index 9c37d646b..adc6d5673 100644 --- a/src/features/profileLinks/components/ProfileLinks.tsx +++ b/src/features/profileLinks/components/ProfileLinks.tsx @@ -11,11 +11,11 @@ import {useLingui} from '@lingui/react/macro' import {useFocusEffect} from '@react-navigation/native' import {useHaptics} from '#/lib/haptics' -import {useOpenLink} from '#/lib/hooks/useOpenLink' import {useSession} from '#/state/session' import {atoms as a, useTheme} from '#/alf' import {Button, ButtonText} from '#/components/Button' import {useDialogControl} from '#/components/Dialog' +import {useLink} from '#/components/Link' import { ReportDialog, useReportDialogControl, @@ -116,11 +116,16 @@ function ProfileLinksRow({ const {t: l} = useLingui() const ax = useAnalytics() const {tap: playTapHaptic, longPress: playLongPressHaptic} = useHaptics() - const openLink = useOpenLink() const previewControl = useDialogControl() const reportControl = useReportDialogControl() const [activeLink, setActiveLink] = useState(null) const [expanded, setExpanded] = useState(false) + // the same handling as tapping the pill, e.g. bsky.app links open in-app + const {onPress: followActiveLink} = useLink({ + to: activeLink?.url ?? '', + displayText: '', + shouldProxy: true, + }) // the profile screen stays mounted elsewhere in the app, so fold back up on leave useFocusEffect( @@ -199,14 +204,9 @@ function ProfileLinksRow({ { + onOpen={(link, e) => { logClick(link) - /* - * The sheet closes before this runs, so unlike the pills it - * can't be a Link. Through the redirect service, so Safelink - * rules apply. - */ - openLink(link.url, undefined, true) + followActiveLink(e) }} onReport={ // nothing to report on your own profile