From 7551de731b7ee18eca0e33978cb171f071106ce2 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Mon, 22 Feb 2021 17:53:44 -0400 Subject: [PATCH] [FIX] Temp attachment files not being flushed after saved to gallery (#2871) * Update AttachmentView.js * Update AttachmentView.js * Update AttachmentView.js * Update AttachmentView.js Co-authored-by: Diego Mello --- app/views/AttachmentView.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/AttachmentView.js b/app/views/AttachmentView.js index 3f4adfec7..c07ed71b9 100644 --- a/app/views/AttachmentView.js +++ b/app/views/AttachmentView.js @@ -121,8 +121,9 @@ class AttachmentView extends React.Component { const extension = image_url ? `.${ mime.extension(image_type) || 'jpg' }` : `.${ mime.extension(video_type) || 'mp4' }`; const documentDir = `${ RNFetchBlob.fs.dirs.DocumentDir }/`; const path = `${ documentDir + SHA256(url) + extension }`; - const file = await RNFetchBlob.config({ path }).fetch('GET', mediaAttachment).then(res => res.path()); - await CameraRoll.save(file, { album: 'Rocket.Chat' }); + const file = await RNFetchBlob.config({ path }).fetch('GET', mediaAttachment); + await CameraRoll.save(path, { album: 'Rocket.Chat' }); + await file.flush(); EventEmitter.emit(LISTENER, { message: I18n.t('saved_to_gallery') }); } catch (e) { EventEmitter.emit(LISTENER, { message: I18n.t(image_url ? 'error-save-image' : 'error-save-video') });