From 71528c89155c632dc506ed7f35ab9699e12deb8a Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Date: Thu, 22 Sep 2022 09:36:56 -0300 Subject: [PATCH 1/4] parse server url --- app/lib/methods/audioFile.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/lib/methods/audioFile.ts b/app/lib/methods/audioFile.ts index 80aa854e107..bd95728f39d 100644 --- a/app/lib/methods/audioFile.ts +++ b/app/lib/methods/audioFile.ts @@ -1,8 +1,11 @@ import * as FileSystem from 'expo-file-system'; +import { sanitizeLikeString } from '../database/utils'; import { store } from '../store/auxStore'; import log from './helpers/log'; +const parseServerUrl = (serverUrl: string) => sanitizeLikeString(serverUrl.substring(serverUrl.lastIndexOf('/') + 1)); + const ensureDirAsync = async (dir: string, intermediates = true): Promise => { const info = await FileSystem.getInfoAsync(dir); if (info.exists && info.isDirectory) { @@ -16,7 +19,7 @@ export const downloadAudioFile = async (url: string, fileUrl: string): Promise => { try { - const serverUrlParsed = serverUrl.substring(serverUrl.lastIndexOf('/') + 1); + const serverUrlParsed = parseServerUrl(serverUrl); const path = `${FileSystem.documentDirectory}audios/${serverUrlParsed}`; await FileSystem.deleteAsync(path); } catch (error) { From bfec112184b40fd00bd68e14997a345923dada90 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Date: Thu, 22 Sep 2022 10:24:50 -0300 Subject: [PATCH 2/4] fix filenames --- app/containers/message/Attachments.tsx | 12 ++++++++++-- app/containers/message/Audio.tsx | 5 +++-- app/containers/message/interfaces.ts | 1 + app/lib/methods/audioFile.ts | 18 +++++++++++++----- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/containers/message/Attachments.tsx b/app/containers/message/Attachments.tsx index ddbed86f03e..25ad98f5918 100644 --- a/app/containers/message/Attachments.tsx +++ b/app/containers/message/Attachments.tsx @@ -57,7 +57,7 @@ const AttachedActions = ({ attachment }: { attachment: IAttachment }) => { }; const Attachments: React.FC = React.memo( - ({ attachments, timeFormat, showAttachment, style, getCustomEmoji, isReply }: IMessageAttachments) => { + ({ attachments, timeFormat, showAttachment, style, getCustomEmoji, isReply, id }: IMessageAttachments) => { const { theme } = useTheme(); if (!attachments || attachments.length === 0) { @@ -80,7 +80,15 @@ const Attachments: React.FC = React.memo( if (file && file.audio_url) { return ( -