about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2025-03-24 19:17:35 +0200
committerGitHub <noreply@github.com>2025-03-24 10:17:35 -0700
commit7daf7a703ef29ca5543e14189a4f019123d1f1e3 (patch)
tree9225a8a98b7c9c8f66d87ea3a44feec4d30815a8 /src
parent6fcf97979be51da20ce4484915624e5c9ac686ef (diff)
downloadvoidsky-7daf7a703ef29ca5543e14189a4f019123d1f1e3.tar.zst
haptics on external link card (#8049)
Diffstat (limited to 'src')
-rw-r--r--src/view/com/util/post-embeds/ExternalLinkEmbed.tsx16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx b/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx
index 5b05cd963..7ca11f60d 100644
--- a/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx
+++ b/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx
@@ -1,11 +1,12 @@
 import React, {useCallback} from 'react'
-import {StyleProp, View, ViewStyle} from 'react-native'
+import {type StyleProp, View, type ViewStyle} from 'react-native'
 import {Image} from 'expo-image'
-import {AppBskyEmbedExternal} from '@atproto/api'
+import {type AppBskyEmbedExternal} from '@atproto/api'
 import {msg} from '@lingui/macro'
 import {useLingui} from '@lingui/react'
 
 import {parseAltFromGIFDescription} from '#/lib/gif-alt-text'
+import {useHaptics} from '#/lib/haptics'
 import {shareUrl} from '#/lib/sharing'
 import {parseEmbedPlayerFromUrl} from '#/lib/strings/embed-player'
 import {toNiceDomain} from '#/lib/strings/url-helpers'
@@ -33,6 +34,7 @@ export const ExternalLinkEmbed = ({
 }) => {
   const {_} = useLingui()
   const t = useTheme()
+  const playHaptic = useHaptics()
   const externalEmbedPrefs = useExternalEmbedsPrefs()
   const niceUrl = toNiceDomain(link.uri)
   const imageUri = link.thumb
@@ -45,11 +47,17 @@ export const ExternalLinkEmbed = ({
   }, [link.uri, externalEmbedPrefs])
   const hasMedia = Boolean(imageUri || embedPlayerParams)
 
+  const onPress = useCallback(() => {
+    playHaptic('Light')
+    onOpen?.()
+  }, [playHaptic, onOpen])
+
   const onShareExternal = useCallback(() => {
     if (link.uri && isNative) {
+      playHaptic('Heavy')
       shareUrl(link.uri)
     }
-  }, [link.uri])
+  }, [link.uri, playHaptic])
 
   if (embedPlayerParams?.source === 'tenor') {
     const parsedAlt = parseAltFromGIFDescription(link.description)
@@ -71,7 +79,7 @@ export const ExternalLinkEmbed = ({
       label={link.title || _(msg`Open link to ${niceUrl}`)}
       to={link.uri}
       shouldProxy={true}
-      onPress={onOpen}
+      onPress={onPress}
       onLongPress={onShareExternal}>
       {({hovered}) => (
         <View