mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(mobile): add bulk download functionality (#18878)
* 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>
This commit is contained in:
parent
1fb8861e35
commit
8733d1e554
8 changed files with 86 additions and 19 deletions
|
|
@ -159,9 +159,19 @@ class DownloadService {
|
|||
return await FileDownloader().cancelTaskWithId(id);
|
||||
}
|
||||
|
||||
Future<List<bool>> downloadAll(List<Asset> assets) async {
|
||||
return await _downloadRepository
|
||||
.downloadAll(assets.expand(_createDownloadTasks).toList());
|
||||
}
|
||||
|
||||
Future<void> download(Asset asset) async {
|
||||
final tasks = _createDownloadTasks(asset);
|
||||
await _downloadRepository.downloadAll(tasks);
|
||||
}
|
||||
|
||||
List<DownloadTask> _createDownloadTasks(Asset asset) {
|
||||
if (asset.isImage && asset.livePhotoVideoId != null && Platform.isIOS) {
|
||||
await _downloadRepository.download(
|
||||
return [
|
||||
_buildDownloadTask(
|
||||
asset.remoteId!,
|
||||
asset.fileName,
|
||||
|
|
@ -171,9 +181,6 @@ class DownloadService {
|
|||
id: asset.remoteId!,
|
||||
).toJson(),
|
||||
),
|
||||
);
|
||||
|
||||
await _downloadRepository.download(
|
||||
_buildDownloadTask(
|
||||
asset.livePhotoVideoId!,
|
||||
asset.fileName
|
||||
|
|
@ -185,16 +192,20 @@ class DownloadService {
|
|||
id: asset.remoteId!,
|
||||
).toJson(),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
await _downloadRepository.download(
|
||||
_buildDownloadTask(
|
||||
asset.remoteId!,
|
||||
asset.fileName,
|
||||
group: asset.isImage ? downloadGroupImage : downloadGroupVideo,
|
||||
),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
if (asset.remoteId == null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
_buildDownloadTask(
|
||||
asset.remoteId!,
|
||||
asset.fileName,
|
||||
group: asset.isImage ? downloadGroupImage : downloadGroupVideo,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
DownloadTask _buildDownloadTask(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue