From fb8316fd85d2d596266e0e1e7c47fa07823e4f98 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Sat, 6 Jun 2026 00:04:21 +0300 Subject: [PATCH] Fix external card long press on web (#10739) --- eslint-suppressions.json | 5 -- .../Post/Embed/ExternalEmbed/index.tsx | 20 +++--- .../Post/Embed/StandardSiteEmbed/index.tsx | 66 ++++++++++--------- 3 files changed, 47 insertions(+), 44 deletions(-) diff --git a/eslint-suppressions.json b/eslint-suppressions.json index b8e65eb265..1c4c89f381 100644 --- a/eslint-suppressions.json +++ b/eslint-suppressions.json @@ -261,11 +261,6 @@ "count": 1 } }, - "src/components/Post/Embed/StandardSiteEmbed/index.tsx": { - "@typescript-eslint/no-floating-promises": { - "count": 3 - } - }, "src/components/Post/Embed/VideoEmbed/VideoEmbedInner/VideoEmbedInnerWeb.tsx": { "@typescript-eslint/no-floating-promises": { "count": 2 diff --git a/src/components/Post/Embed/ExternalEmbed/index.tsx b/src/components/Post/Embed/ExternalEmbed/index.tsx index 472c403060..9a4f7e56bc 100644 --- a/src/components/Post/Embed/ExternalEmbed/index.tsx +++ b/src/components/Post/Embed/ExternalEmbed/index.tsx @@ -1,4 +1,4 @@ -import {useCallback, useMemo} from 'react' +import {useMemo} from 'react' import {type StyleProp, View, type ViewStyle} from 'react-native' import {Image} from 'expo-image' import {type AppBskyEmbedExternal} from '@atproto/api' @@ -51,17 +51,19 @@ export const ExternalEmbed = ({ }, [link.uri, externalEmbedPrefs]) const hasMedia = Boolean(imageUri || embedPlayerParams) - const onPress = useCallback(() => { + const onPress = () => { playHaptic('Light') onOpen?.() - }, [playHaptic, onOpen]) + } - const onShareExternal = useCallback(() => { - if (link.uri && IS_NATIVE) { - playHaptic('Heavy') - void shareUrl(link.uri) - } - }, [link.uri, playHaptic]) + const onShareExternal = IS_NATIVE + ? () => { + if (link.uri) { + playHaptic('Heavy') + void shareUrl(link.uri) + } + } + : undefined if ( embedPlayerParams?.source === 'tenor' || diff --git a/src/components/Post/Embed/StandardSiteEmbed/index.tsx b/src/components/Post/Embed/StandardSiteEmbed/index.tsx index 2bee7da91e..b328bc38ff 100644 --- a/src/components/Post/Embed/StandardSiteEmbed/index.tsx +++ b/src/components/Post/Embed/StandardSiteEmbed/index.tsx @@ -79,13 +79,15 @@ export const StandardSiteEmbed = ({ onEmbedInteractionCallback?.() ax.metric('embed:standardSite:article:press', {url: view.uri}) } - const onLongPress = () => { - if (view.uri && IS_NATIVE) { - playHaptic('Heavy') - shareUrl(view.uri) - ax.metric('embed:standardSite:article:longPress', {url: view.uri}) - } - } + const onLongPress = IS_NATIVE + ? () => { + if (view.uri) { + playHaptic('Heavy') + void shareUrl(view.uri) + ax.metric('embed:standardSite:article:longPress', {url: view.uri}) + } + } + : undefined const onPressPublication = () => { playHaptic('Light') onEmbedInteractionCallback?.() @@ -93,15 +95,17 @@ export const StandardSiteEmbed = ({ url: view.source?.uri || '', }) } - const onLongPressPublication = () => { - if (view.source?.uri && IS_NATIVE) { - playHaptic('Heavy') - shareUrl(view.source.uri) - ax.metric('embed:standardSite:publication:longPress', { - url: view.source.uri, - }) - } - } + const onLongPressPublication = IS_NATIVE + ? () => { + if (view.source?.uri) { + playHaptic('Heavy') + void shareUrl(view.source.uri) + ax.metric('embed:standardSite:publication:longPress', { + url: view.source.uri, + }) + } + } + : undefined if (isStandardPublication) { return ( @@ -465,21 +469,23 @@ export function SubscribeButton({ } } - const onLongPress = () => { - if (view.source?.uri && IS_NATIVE) { - playHaptic('Heavy') - shareUrl(view.source.uri) - if (highlightedPublisher) { - ax.metric('embed:standardSite:subscribe:longPress', { - url: view.source?.uri || '', - }) - } else { - ax.metric('embed:standardSite:publicationCta:longPress', { - url: view.source?.uri || '', - }) + const onLongPress = IS_NATIVE + ? () => { + if (view.source?.uri) { + playHaptic('Heavy') + void shareUrl(view.source.uri) + if (highlightedPublisher) { + ax.metric('embed:standardSite:subscribe:longPress', { + url: view.source?.uri || '', + }) + } else { + ax.metric('embed:standardSite:publicationCta:longPress', { + url: view.source?.uri || '', + }) + } + } } - } - } + : undefined const button = (