Skip to content

feat(mobile): add bulk download functionality - #18878

Merged
alextran1502 merged 9 commits into
immich-app:mainfrom
JobiJoba:download-in-multi-select-files
Jun 4, 2025
Merged

alextran1502 merged 9 commits into
immich-app:mainfrom
JobiJoba:download-in-multi-select-files

Conversation

@JobiJoba

@JobiJoba JobiJoba commented Jun 3, 2025

Copy link
Copy Markdown
Contributor
  • Added downloadAll method to IDownloadRepository and its implementation in DownloadRepository to handle multiple asset downloads.
  • Implemented downloadAllAsset in DownloadStateNotifier to trigger bulk downloads.
  • Updated DownloadService to create download tasks for all selected assets.
  • Enhanced UI with new download success and failure messages in en.json.
  • Added download button to ControlBottomAppBar and integrated download functionality in MultiselectGrid.

Description

Feature request from #5068

Few decision has been taken:

  1. Allow to download a file only if he's present remotely (even if he's already present locally also) ; This is a feature that I often use when I lost a picture but could find it in Google Photos, by downloading it; it create a copy but at the top of the stack of my photos.
  2. In the gallery asset; we can only download a picture if it's remote and non-local; I would like to change this to be the same as the multi-download
  3. Because we can select multiple state of an asset, sometimes it can be remote only, local only, remote and local; I've adapted the message to show a "download (count) files successful - (error) files failed"

I've made a small typo fix which is not really related to this issue here:

      'SelectionAssetState(hasRemote: $hasRemote, hasMerged: $hasMerged, hasMerged: $hasMerged, selectedCount: $selectedCount)';

   'SelectionAssetState(hasRemote: $hasRemote, hasLocal: $hasLocal, hasMerged: $hasMerged, selectedCount: $selectedCount)';

(hasMerged was there two time instead of hasLocal)

--

I think how it works currently is ok but in a better world I would like to also let people download a picture that is only local.
What do you think?

Fixes # (issue)

How Has This Been Tested?

  • Select multiple or one asset(s) which are present remotely
  • Check that the download button is present
  • Click on the download button
  • Check if the images are in your local library

--

  • Select a non remote asset
  • Check that the download button is not present

--

  • Select a non remote and a remote asset
  • Check that the button download is present
  • Check that the remote image is well downloaded.

Screenshots (if appropriate)

92083

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if applicable
  • I have no unrelated changes in the PR.
  • I have confirmed that any new dependencies are strictly necessary.
  • I have written tests for new code (if applicable)
  • I have followed naming conventions/patterns in the surrounding code
  • All code in src/services/ uses repositories implementations for database calls, filesystem operations, etc.
  • All code in src/repositories/ is pretty basic/simple and does not have any immich specific logic (that belongs in src/services/)

- Added `downloadAll` method to `IDownloadRepository` and its implementation in `DownloadRepository` to handle multiple asset downloads.
- Implemented `downloadAllAsset` in `DownloadStateNotifier` to trigger bulk downloads.
- Updated `DownloadService` to create download tasks for all selected assets.
- Enhanced UI with new download success and failure messages in `en.json`.
- Added download button to `ControlBottomAppBar` and integrated download functionality in `MultiselectGrid`.
@JobiJoba JobiJoba changed the title feat(mobile): add bulk download functionality and update UI messages feat(mobile): add bulk download functionality Jun 3, 2025
Comment thread i18n/en.json Outdated

@alextran1502 alextran1502 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very clear and concise code! Thanks

@shenlong-tanwen shenlong-tanwen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Kindly address the comments and update the translation strings to use ICU message format. Thanks for the contribution

Comment thread mobile/lib/services/download.service.dart Outdated
Comment thread mobile/lib/services/download.service.dart Outdated
Comment thread mobile/lib/services/download.service.dart Outdated
JobiJoba and others added 4 commits June 3, 2025 16:42
Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com>
- Changed the download method to utilize downloadAll for handling multiple tasks.
- Simplified remoteId check by removing unnecessary condition.
@JobiJoba

JobiJoba commented Jun 3, 2025 •

Copy link
Copy Markdown
Contributor Author

All changes from @shenlong-tanwen done; thanks for the review

@JobiJoba

JobiJoba commented Jun 4, 2025

Copy link
Copy Markdown
Contributor Author

I'm not sure what makes the i18 fail - someone does have an idea?

@shenlong-tanwen

shenlong-tanwen commented Jun 4, 2025 •

Copy link
Copy Markdown
Member

I'm not sure what makes the i18 fail - someone does have an idea?

The keys in the translation file must be sorted. You can run the following command from the root directory npm --prefix=web run format:i18n to fix it

@JobiJoba

JobiJoba commented Jun 4, 2025

Copy link
Copy Markdown
Contributor Author

Thanks @shenlong-tanwen ;

Do you think we should remove

@override
  Future<bool> download(DownloadTask task) {
    return FileDownloader().enqueue(task);
  }

as it is not used anywhere now?

or should I maybe modify the logic to if only one task call the download method, else call the downloadAll?

I've tried with one asset and multiple asset; all of them download the file correctly

@shenlong-tanwen

Copy link
Copy Markdown
Member

We can remove it and keep things simple. Thanks a lot for working on this

@alextran1502

Copy link
Copy Markdown
Member

Tested and worked well! One potential complaint I can foresee is that "there is no progress bar for the bulk download, so I don't know when it is done"

@alextran1502
alextran1502 merged commit 8733d1e into immich-app:main Jun 4, 2025
@JobiJoba

JobiJoba commented Jun 5, 2025

Copy link
Copy Markdown
Contributor Author

I was thinking the same, want me to look at how to add the progress bar? (I've tried to add the component but it didn't work but I didn't really look into it)

@akostadinov

Copy link
Copy Markdown

Thank you for the great feature. A couple of suggestions.

I think that downloading a copy by default is suboptimal. Why not make it a non-default user preference or have a separate Download a copy button?

Also showing the file at the top of the stack, does it mean mtime is being messed up?

savely-krasovsky pushed a commit to savely-krasovsky/immich that referenced this pull request Jun 8, 2025
* feat(mobile): add bulk download functionality and update UI messages

- Added `downloadAll` method to `IDownloadRepository` and its implementation in `DownloadRepository` to handle multiple asset downloads.
- Implemented `downloadAllAsset` in `DownloadStateNotifier` to trigger bulk downloads.
- Updated `DownloadService` to create download tasks for all selected assets.
- Enhanced UI with new download success and failure messages in `en.json`.
- Added download button to `ControlBottomAppBar` and integrated download functionality in `MultiselectGrid`.

* translations use i18n method t()

* Update mobile/lib/services/download.service.dart

Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com>

* fix(mobile): update download logic in DownloadService

- Changed the download method to utilize downloadAll for handling multiple tasks.
- Simplified remoteId check by removing unnecessary condition.

* sort i18n keys

* remove the download signature from interface and logic as we use the downloadAll now

---------

Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants