From d29599fa6cc2c402ae38417e114c0aee4db5d55b Mon Sep 17 00:00:00 2001
From: Frudrax Cheng <i@cynosura.one>
Date: Sun, 24 Nov 2024 01:25:14 +0800
Subject: Fix translate button not working (#6657)

* Update PostThreadItem.tsx

* Fix in-app browser usage

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
---
 src/view/com/post-thread/PostThreadItem.tsx | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

(limited to 'src/view/com/post-thread/PostThreadItem.tsx')

diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx
index f2b719a84..035f7a681 100644
--- a/src/view/com/post-thread/PostThreadItem.tsx
+++ b/src/view/com/post-thread/PostThreadItem.tsx
@@ -1,5 +1,10 @@
 import React, {memo, useMemo} from 'react'
-import {StyleSheet, Text as RNText, View} from 'react-native'
+import {
+  GestureResponderEvent,
+  StyleSheet,
+  Text as RNText,
+  View,
+} from 'react-native'
 import {
   AppBskyFeedDefs,
   AppBskyFeedPost,
@@ -736,9 +741,14 @@ function ExpandedPostDetails({
   const openLink = useOpenLink()
   const isRootPost = !('reply' in post.record)
 
-  const onTranslatePress = React.useCallback(() => {
-    openLink(translatorUrl, true)
-  }, [openLink, translatorUrl])
+  const onTranslatePress = React.useCallback(
+    (e: GestureResponderEvent) => {
+      e.preventDefault()
+      openLink(translatorUrl, true)
+      return false
+    },
+    [openLink, translatorUrl],
+  )
 
   return (
     <View style={[a.gap_md, a.pt_md, a.align_start]}>
@@ -757,7 +767,7 @@ function ExpandedPostDetails({
             </Text>
 
             <InlineLinkText
-              to="#"
+              to={translatorUrl}
               label={_(msg`Translate`)}
               style={[a.text_sm, pal.link]}
               onPress={onTranslatePress}>
-- 
cgit 1.4.1

