diff --git a/app/i18n/locales/en.js b/app/i18n/locales/en.js
index 6b485ea7..e89b9df7 100644
--- a/app/i18n/locales/en.js
+++ b/app/i18n/locales/en.js
@@ -18,6 +18,7 @@ export default {
'error-email-domain-blacklisted': 'The email domain is blacklisted',
'error-email-send-failed': 'Error trying to send email: {{message}}',
'error-save-image': 'Error while saving image',
+ 'error-save-video': 'Error while saving video',
'error-field-unavailable': '{{field}} is already in use :(',
'error-file-too-large': 'File is too large',
'error-importer-not-defined': 'The importer was not defined correctly, it is missing the Import class.',
diff --git a/app/views/AttachmentView.js b/app/views/AttachmentView.js
index 51646896..c94a8e84 100644
--- a/app/views/AttachmentView.js
+++ b/app/views/AttachmentView.js
@@ -33,11 +33,11 @@ class AttachmentView extends React.Component {
const attachment = navigation.getParam('attachment');
const from = navigation.getParam('from');
const handleSave = navigation.getParam('handleSave', () => {});
- const { title, video_url } = attachment;
+ const { title } = attachment;
const options = {
title,
...themedHeader(theme),
- headerRight: !video_url ? : null
+ headerRight:
};
if (from !== 'MessagesView') {
options.gesturesEnabled = false;
@@ -84,8 +84,11 @@ class AttachmentView extends React.Component {
handleSave = async() => {
const { attachment } = this.state;
const { user, baseUrl } = this.props;
- const { image_url, image_type } = attachment;
- const img = formatAttachmentUrl(image_url, user.id, user.token, baseUrl);
+ const {
+ image_url, image_type, video_url, video_type
+ } = attachment;
+ const url = image_url || video_url;
+ const mediaAttachment = formatAttachmentUrl(url, user.id, user.token, baseUrl);
if (isAndroid) {
const rationale = {
@@ -100,13 +103,13 @@ class AttachmentView extends React.Component {
this.setState({ loading: true });
try {
- const extension = `.${ mime.extension(image_type) || 'jpg' }`;
- const file = `${ FileSystem.documentDirectory + SHA256(image_url) + extension }`;
- const { uri } = await FileSystem.downloadAsync(img, file);
+ const extension = image_url ? `.${ mime.extension(image_type) || 'jpg' }` : `.${ mime.extension(video_type) || 'mp4' }`;
+ const file = `${ FileSystem.documentDirectory + SHA256(url) + extension }`;
+ const { uri } = await FileSystem.downloadAsync(mediaAttachment, file);
await CameraRoll.save(uri, { album: 'Rocket.Chat' });
EventEmitter.emit(LISTENER, { message: I18n.t('saved_to_gallery') });
} catch (e) {
- EventEmitter.emit(LISTENER, { message: I18n.t('error-save-image') });
+ EventEmitter.emit(LISTENER, { message: I18n.t(image_url ? 'error-save-image' : 'error-save-video') });
}
this.setState({ loading: false });
};