소스 검색

attachments fix

Viktoriia 4 달 전
부모
커밋
8ff25ae9cc

+ 10 - 11
src/screens/InAppScreens/MessagesScreen/ChatScreen/index.tsx

@@ -186,7 +186,8 @@ const ChatScreen = ({ route }: { route: any }) => {
             id: -1,
             filename: file.type,
             filetype: file.type,
-            attachment_link: file.uri
+            attachment_link: file.uri,
+            attachment_full_url: file.uri
           },
           pending: true,
           isSending: true,
@@ -235,15 +236,7 @@ const ChatScreen = ({ route }: { route: any }) => {
                   ? {
                       ...msg,
                       _id: res.message_id,
-                      attachment: res.attachment,
-                      isSending: false,
-                      image:
-                        res.attachment?.attachment_small_url && file.type === 'image'
-                          ? API_HOST + res.attachment.attachment_small_url
-                          : undefined,
-                      video: res.attachment?.attachment_link
-                        ? API_HOST + res.attachment.attachment_link
-                        : undefined
+                      isSending: false
                     }
                   : msg
               )
@@ -1460,7 +1453,13 @@ const ChatScreen = ({ route }: { route: any }) => {
 
     return (
       <TouchableOpacity
-        onPress={() => setSelectedMedia(API_HOST + currentMessage.attachment.attachment_full_url)}
+        onPress={() =>
+          setSelectedMedia(
+            currentMessage.attachment.attachment_full_url?.startsWith('/')
+              ? API_HOST + currentMessage.attachment.attachment_full_url
+              : currentMessage.attachment.attachment_full_url
+          )
+        }
         onLongPress={() => handleLongPress(currentMessage, props)}
         style={styles.imageContainer}
         disabled={currentMessage.isSending}

+ 6 - 0
src/screens/InAppScreens/MessagesScreen/Components/renderMessageVideo.tsx

@@ -30,6 +30,12 @@ const RenderMessageVideo = ({
   const [isVideoLoaded, setIsVideoLoaded] = useState(false);
 
   const downloadVideo = async (videoUrl: string) => {
+    if (!videoUrl.startsWith('https')) {
+      setVideoUri(videoUrl);
+      setIsVideoLoaded(true);
+      return videoUrl;
+    }
+
     try {
       const dirExist = await FileSystem.getInfoAsync(CACHED_ATTACHMENTS_DIR);
       if (!dirExist.exists) {

+ 10 - 11
src/screens/InAppScreens/MessagesScreen/GroupChatScreen/index.tsx

@@ -192,7 +192,8 @@ const GroupChatScreen = ({ route }: { route: any }) => {
             id: -1,
             filename: file.type,
             filetype: file.type,
-            attachment_link: file.uri
+            attachment_link: file.uri,
+            attachment_full_url: file.uri
           },
           pending: true,
           isSending: true,
@@ -242,15 +243,7 @@ const GroupChatScreen = ({ route }: { route: any }) => {
                   ? {
                       ...msg,
                       _id: res.message_id,
-                      attachment: res.attachment,
-                      isSending: false,
-                      image:
-                        res.attachment?.attachment_small_url && file.type === 'image'
-                          ? API_HOST + res.attachment.attachment_small_url
-                          : undefined,
-                      video: res.attachment?.attachment_link
-                        ? API_HOST + res.attachment.attachment_link
-                        : undefined
+                      isSending: false
                     }
                   : msg
               )
@@ -1527,7 +1520,13 @@ const GroupChatScreen = ({ route }: { route: any }) => {
 
     return (
       <TouchableOpacity
-        onPress={() => setSelectedMedia(API_HOST + currentMessage.attachment.attachment_full_url)}
+        onPress={() =>
+          setSelectedMedia(
+            currentMessage.attachment.attachment_full_url?.startsWith('/')
+              ? API_HOST + currentMessage.attachment.attachment_full_url
+              : currentMessage.attachment.attachment_full_url
+          )
+        }
         onLongPress={() => handleLongPress(currentMessage, props)}
         style={styles.imageContainer}
         disabled={currentMessage.isSending}