Unverified Commit 7551de73 authored by Gerzon Z's avatar Gerzon Z Committed by GitHub
Browse files

[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: default avatarDiego Mello <diegolmello@gmail.com>
parent f5796416
......@@ -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') });
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment