Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d0af3c0
Merge pull request #1 from RocketChat/develop
Prateek93a Oct 29, 2019
5eeb5ce
Merge pull request #2 from RocketChat/develop
Prateek93a Dec 5, 2019
eb42238
Merge branch 'develop' of https://github.com/Prateek93a/Rocket.Chat.R…
Prateek93a Feb 22, 2020
45ac82a
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Feb 22, 2020
827cd42
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Mar 2, 2020
169c159
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Mar 4, 2020
4350cde
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Mar 11, 2020
9d0c8ec
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Mar 14, 2020
bb4d912
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Mar 22, 2020
bee1920
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 1, 2020
d48214d
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 1, 2020
e25eb0f
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 1, 2020
fa773ae
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 3, 2020
c2e3dc1
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 4, 2020
28d0419
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 8, 2020
0aff35f
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 10, 2020
bc57534
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 14, 2020
3bc743a
Merge branch 'develop' of https://github.com/RocketChat/Rocket.Chat.R…
Prateek93a Apr 15, 2020
3378043
added-feature-save-video
Prateek93a Apr 25, 2020
c9d2ad8
fix sha256
djorkaeffalexandre Apr 27, 2020
af9e661
Merge branch 'develop' into save-video
diegolmello Apr 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/i18n/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
17 changes: 10 additions & 7 deletions app/views/AttachmentView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? <SaveButton testID='save-image' onPress={handleSave} /> : null
headerRight: <SaveButton testID='save-image' onPress={handleSave} />
};
if (from !== 'MessagesView') {
options.gesturesEnabled = false;
Expand Down Expand Up @@ -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 = {
Expand All @@ -100,13 +103,13 @@ class AttachmentView extends React.Component {

this.setState({ loading: true });
try {
const extension = `.${ mime.extension(image_type) || 'jpg' }`;
const extension = image_url ? `.${ mime.extension(image_type) || 'jpg' }` : `.${ mime.extension(video_type) || 'mp4' }`;
const file = `${ FileSystem.documentDirectory + SHA256(image_url) + extension }`;
const { uri } = await FileSystem.downloadAsync(img, file);
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 });
};
Expand Down