mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -04:00
* 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>
69 lines
2.0 KiB
Dart
69 lines
2.0 KiB
Dart
import 'package:background_downloader/background_downloader.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/interfaces/download.interface.dart';
|
|
import 'package:immich_mobile/utils/download.dart';
|
|
|
|
final downloadRepositoryProvider = Provider((ref) => DownloadRepository());
|
|
|
|
class DownloadRepository implements IDownloadRepository {
|
|
@override
|
|
void Function(TaskStatusUpdate)? onImageDownloadStatus;
|
|
|
|
@override
|
|
void Function(TaskStatusUpdate)? onVideoDownloadStatus;
|
|
|
|
@override
|
|
void Function(TaskStatusUpdate)? onLivePhotoDownloadStatus;
|
|
|
|
@override
|
|
void Function(TaskProgressUpdate)? onTaskProgress;
|
|
|
|
DownloadRepository() {
|
|
FileDownloader().registerCallbacks(
|
|
group: downloadGroupImage,
|
|
taskStatusCallback: (update) => onImageDownloadStatus?.call(update),
|
|
taskProgressCallback: (update) => onTaskProgress?.call(update),
|
|
);
|
|
|
|
FileDownloader().registerCallbacks(
|
|
group: downloadGroupVideo,
|
|
taskStatusCallback: (update) => onVideoDownloadStatus?.call(update),
|
|
taskProgressCallback: (update) => onTaskProgress?.call(update),
|
|
);
|
|
|
|
FileDownloader().registerCallbacks(
|
|
group: downloadGroupLivePhoto,
|
|
taskStatusCallback: (update) => onLivePhotoDownloadStatus?.call(update),
|
|
taskProgressCallback: (update) => onTaskProgress?.call(update),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Future<List<bool>> downloadAll(List<DownloadTask> tasks) {
|
|
return FileDownloader().enqueueAll(tasks);
|
|
}
|
|
|
|
@override
|
|
Future<void> deleteAllTrackingRecords() {
|
|
return FileDownloader().database.deleteAllRecords();
|
|
}
|
|
|
|
@override
|
|
Future<bool> cancel(String id) {
|
|
return FileDownloader().cancelTaskWithId(id);
|
|
}
|
|
|
|
@override
|
|
Future<List<TaskRecord>> getLiveVideoTasks() {
|
|
return FileDownloader().database.allRecordsWithStatus(
|
|
TaskStatus.complete,
|
|
group: downloadGroupLivePhoto,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Future<void> deleteRecordsWithIds(List<String> ids) {
|
|
return FileDownloader().database.deleteRecordsWithIds(ids);
|
|
}
|
|
}
|