[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 <diegolmello@gmail.com>
This commit is contained in:
parent
f579641660
commit
7551de731b
|
@ -121,8 +121,9 @@ class AttachmentView extends React.Component {
|
||||||
const extension = image_url ? `.${ mime.extension(image_type) || 'jpg' }` : `.${ mime.extension(video_type) || 'mp4' }`;
|
const extension = image_url ? `.${ mime.extension(image_type) || 'jpg' }` : `.${ mime.extension(video_type) || 'mp4' }`;
|
||||||
const documentDir = `${ RNFetchBlob.fs.dirs.DocumentDir }/`;
|
const documentDir = `${ RNFetchBlob.fs.dirs.DocumentDir }/`;
|
||||||
const path = `${ documentDir + SHA256(url) + extension }`;
|
const path = `${ documentDir + SHA256(url) + extension }`;
|
||||||
const file = await RNFetchBlob.config({ path }).fetch('GET', mediaAttachment).then(res => res.path());
|
const file = await RNFetchBlob.config({ path }).fetch('GET', mediaAttachment);
|
||||||
await CameraRoll.save(file, { album: 'Rocket.Chat' });
|
await CameraRoll.save(path, { album: 'Rocket.Chat' });
|
||||||
|
await file.flush();
|
||||||
EventEmitter.emit(LISTENER, { message: I18n.t('saved_to_gallery') });
|
EventEmitter.emit(LISTENER, { message: I18n.t('saved_to_gallery') });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
EventEmitter.emit(LISTENER, { message: I18n.t(image_url ? 'error-save-image' : 'error-save-video') });
|
EventEmitter.emit(LISTENER, { message: I18n.t(image_url ? 'error-save-image' : 'error-save-video') });
|
||||||
|
|
Loading…
Reference in New Issue