Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add media auto-download #5076

Merged
merged 78 commits into from
Aug 7, 2023

Conversation

reinaldonetof
Copy link
Contributor

@reinaldonetof reinaldonetof commented May 16, 2023

Proposed changes

Here we present the Media Auto-Download feature, which allows users to manage the download of Images, Videos, and Audio files. There are three available states: Never, Wifi, and Wifi & Mobile Data.

Auto-download of files occurs when the state is set to Wifi and the device is connected to a Wifi network, or when it is set to Wifi & Mobile Data, or when the user is the same author of the message.

When the Never state is selected or when the state is set to Wifi but the device is using mobile data:

  • Audio: No files will be cached except those sent by the user. The user needs to press the download icon, and playback will only be possible after the complete download is finished. Meanwhile, the file will be downloaded.

  • Image: No files will be cached except those sent by the user. The user needs to press the download icon, and playback will only be possible after the complete download is finished. While downloading, if the user clicks on the image again, the download will be canceled.

  • Video: No files will be cached, including those sent by the user. When the user clicks the play button, the video player will open and start playing the video using the provided link while simultaneously downloading the video. If the user closes the video player and the download is still in progress, they will see a loading icon and the option to "Cancel" the download.

When the state is set to Wifi and the device is connected to a wifi network, or when the state is set to Wifi & Mobile Data, all audio, video, and image files that appear will automatically initiate the download.

Issue(s)

How to test or reproduce

Screenshots

Audio

Screen.Recording.2023-07-24.at.20.18.10.mov

Image

Screen.Recording.2023-07-24.at.20.34.58.mov

Video

Screen.Recording.2023-07-24.at.20.14.23.mov

All medis wifi

all-wifi.mov

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

TC-579

@reinaldonetof reinaldonetof self-assigned this May 16, 2023
Comment on lines +73 to +77
// The return of mime.extension('video/quicktime') is .qt,
// this format the iOS isn't recognize and can't save on gallery
if (mimeType === 'video/quicktime') {
return 'mov';
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// The return of mime.extension('video/quicktime') is .qt,
// this format the iOS isn't recognize and can't save on gallery
const documentDir = `${RNFetchBlob.fs.dirs.DocumentDir}/`;
const path = `${documentDir + sha256(url) + extension}`;
const file = await RNFetchBlob.config({ path }).fetch('GET', mediaAttachment);
await CameraRoll.save(path, { album: 'Rocket.Chat' });

@dnlsilva dnlsilva requested a review from diegolmello July 11, 2023 20:53
Copy link
Member

@diegolmello diegolmello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do a performance review of this PR, please.

@reinaldonetof reinaldonetof merged commit c9f4ca1 into develop Aug 7, 2023
@reinaldonetof reinaldonetof deleted the feat.media-auto-download-preference branch August 7, 2023 14:02
@nmagedman
Copy link
Contributor

@reinaldonetof Before this PR, what was the behavior of downloading image attachments? Did it always auto-download images or did it never auto-download (and instead would wait until the user tapped on the image preview thumbnail)?

@dnlsilva
Copy link
Contributor

@nmagedman for images the previous behavior is always download.

@diegolmello
Copy link
Member

@nmagedman URLs didn't change. We just changed the moment we fetch media, which might have caused the impression of being slower.
Let's focus the discussion on #5237 from now on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants