|
@@ -543,8 +543,13 @@ const ChatScreen = ({ route }: { route: any }) => {
|
|
const fileUrl = currentMessage.video
|
|
const fileUrl = currentMessage.video
|
|
? currentMessage.video
|
|
? currentMessage.video
|
|
: API_HOST + currentMessage.attachment?.attachment_full_url;
|
|
: API_HOST + currentMessage.attachment?.attachment_full_url;
|
|
- const fileType = currentMessage.attachment?.filetype || '';
|
|
|
|
- const fileExt = fileType.split('/').pop() || '';
|
|
|
|
|
|
+ const fileType = currentMessage.attachment?.filetype || 'application/octet-stream';
|
|
|
|
+ let fileExt = fileType.split('/').pop() || (currentMessage.video ? 'mp4' : 'jpg');
|
|
|
|
+
|
|
|
|
+ if (Platform.OS === 'android' && fileType === 'video/quicktime') {
|
|
|
|
+ fileExt = 'mp4';
|
|
|
|
+ }
|
|
|
|
+
|
|
const fileName = currentMessage.attachment?.filename?.split('.')[0] || 'file';
|
|
const fileName = currentMessage.attachment?.filename?.split('.')[0] || 'file';
|
|
const fileUri = `${FileSystem.cacheDirectory}${fileName}.${fileExt}`;
|
|
const fileUri = `${FileSystem.cacheDirectory}${fileName}.${fileExt}`;
|
|
|
|
|
|
@@ -554,9 +559,9 @@ const ChatScreen = ({ route }: { route: any }) => {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- const downloadOptions = currentMessage.video
|
|
|
|
- ? { headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS } }
|
|
|
|
- : undefined;
|
|
|
|
|
|
+ const downloadOptions = {
|
|
|
|
+ headers: { Nmtoken: token, 'App-Version': APP_VERSION, Platform: Platform.OS }
|
|
|
|
+ };
|
|
const { uri } = await FileSystem.downloadAsync(fileUrl, fileUri, downloadOptions);
|
|
const { uri } = await FileSystem.downloadAsync(fileUrl, fileUri, downloadOptions);
|
|
|
|
|
|
await MediaLibrary.createAssetAsync(uri);
|
|
await MediaLibrary.createAssetAsync(uri);
|
|
@@ -569,6 +574,7 @@ const ChatScreen = ({ route }: { route: any }) => {
|
|
Alert.alert('Error', 'Failed to download the file.');
|
|
Alert.alert('Error', 'Failed to download the file.');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
const renderMessageFile = (props: BubbleProps<CustomMessage>) => {
|
|
const renderMessageFile = (props: BubbleProps<CustomMessage>) => {
|
|
const { currentMessage } = props;
|
|
const { currentMessage } = props;
|
|
const leftMessage = currentMessage?.user?._id !== +currentUserId;
|
|
const leftMessage = currentMessage?.user?._id !== +currentUserId;
|