From ce67d05852dc83e4d47eaef7a09606baf6d69b7d Mon Sep 17 00:00:00 2001 From: Reinaldo Neto Date: Fri, 19 May 2023 11:52:22 -0300 Subject: [PATCH] clean up --- app/containers/message/Audio.tsx | 14 +------------- app/containers/message/Image.tsx | 5 ++--- app/lib/methods/handleMediaDownload.ts | 3 +-- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/app/containers/message/Audio.tsx b/app/containers/message/Audio.tsx index fe2224022..6a68db0ef 100644 --- a/app/containers/message/Audio.tsx +++ b/app/containers/message/Audio.tsx @@ -154,19 +154,7 @@ class MessageAudio extends React.Component { - console.log('🚀 ~ file: Audio.tsx:162 ~ MessageAudio ~ awaitthis.sound.loadAsync ~ value:', value); - }) - .catch(er => { - console.log('🚀 ~ file: Audio.tsx:158 ~ MessageAudio ~ awaitthis.sound.loadAsync ~ er:', er); - }); + await this.sound.loadAsync({ uri: fileSearch.file.uri }); return this.setState({ loading: false }); } await this.handleAutoDownload(); diff --git a/app/containers/message/Image.tsx b/app/containers/message/Image.tsx index 9fa444598..772d32fe6 100644 --- a/app/containers/message/Image.tsx +++ b/app/containers/message/Image.tsx @@ -103,7 +103,7 @@ const ImageContainer = React.memo( const [loading, setLoading] = useState(false); const { theme } = useTheme(); const { baseUrl, user } = useContext(MessageContext); - const img = imageUrl || formatAttachmentUrl(newFile.image_url, user.id, user.token, baseUrl); + const img = imageUrl || formatAttachmentUrl(file.image_url, user.id, user.token, baseUrl); const filePath = useRef(''); useLayoutEffect(() => { @@ -144,7 +144,7 @@ const ImageContainer = React.memo( setLoading(true); try { // The param file.title_link is the one that point to image with best quality, however we still need to test the imageUrl - // And we don't have sure that exists the file.title_link + // And we don't have sure that ever exists the file.title_link const imgUrl = imageUrl || formatAttachmentUrl(newFile.title_link || newFile.image_url, user.id, user.token, baseUrl); const imageUri = await downloadMediaFile({ downloadUrl: imgUrl, @@ -160,7 +160,6 @@ const ImageContainer = React.memo( setToDownload(false); setLoading(false); } catch (e) { - console.log('🚀 ~ file: Image.tsx:164 ~ handleDownload ~ e:', e); setLoading(false); return setToDownload(true); } diff --git a/app/lib/methods/handleMediaDownload.ts b/app/lib/methods/handleMediaDownload.ts index b49ecb971..7ed5baebe 100644 --- a/app/lib/methods/handleMediaDownload.ts +++ b/app/lib/methods/handleMediaDownload.ts @@ -35,14 +35,12 @@ export function isDownloadActive(mediaType: MediaTypes, messageId: string): bool export async function cancelDownload(mediaType: MediaTypes, messageId: string): Promise { const downloadKey = mediaDownloadKey(mediaType, messageId); if (!isEmpty(downloadQueue[downloadKey])) { - console.log('🚀 ~ file: handleMediaDownload.ts:38 ~ cancelDownload ~ downloadQueue:', downloadQueue); try { await downloadQueue[downloadKey].cancel(); } catch { // Do nothing } delete downloadQueue[downloadKey]; - console.log('🚀 ~ file: handleMediaDownload.ts:47 ~ cancelDownload ~ downloadQueue:', downloadQueue); } } @@ -63,6 +61,7 @@ export function downloadMediaFile({ timeout: 10000, indicator: true, overwrite: true, + // The RNFetchBlob just save the file when didn't exist the file:// at the begin of path path: path.replace('file://', '') }; downloadQueue[downloadKey] = RNFetchBlob.config(options).fetch('GET', downloadUrl);