High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
chore: refactor download group (#20099)
Alexc7853fbe9d59
diff --git a/mobile/lib/constants/constants.dart b/mobile/lib/constants/constants.dartindex b54a1e9ca2..b3d9d138c4 100644--- a/mobile/lib/constants/constants.dart+++ b/mobile/lib/constants/constants.dart@@ -20,6 +20,9 @@ const String kSecuredPinCode = "secured_pin_code";const String kManualUploadGroup = 'manual_upload_group';const String kBackupGroup = 'backup_group';const String kBackupLivePhotoGroup = 'backup_live_photo_group';+const String kDownloadGroupImage = 'group_image';+const String kDownloadGroupVideo = 'group_video';+const String kDownloadGroupLivePhoto = 'group_livephoto';// Timeline constantsconst int kTimelineNoneSegmentSize = 120;diff --git a/mobile/lib/main.dart b/mobile/lib/main.dartindex f036fd9bc3..9f39a89b33 100644--- a/mobile/lib/main.dart+++ b/mobile/lib/main.dart@@ -10,6 +10,7 @@ import 'package:flutter/material.dart';import 'package:flutter/services.dart';import 'package:flutter_displaymode/flutter_displaymode.dart';import 'package:hooks_riverpod/hooks_riverpod.dart';+import 'package:immich_mobile/constants/constants.dart';import 'package:immich_mobile/constants/locales.dart';import 'package:immich_mobile/extensions/build_context_extensions.dart';import 'package:immich_mobile/generated/codegen_loader.g.dart';@@ -29,7 +30,6 @@ import 'package:immich_mobile/theme/dynamic_theme.dart';import 'package:immich_mobile/theme/theme_data.dart';import 'package:immich_mobile/utils/bootstrap.dart';import 'package:immich_mobile/utils/cache/widgets_binding.dart';-import 'package:immich_mobile/utils/download.dart';import 'package:immich_mobile/utils/http_ssl_options.dart';import 'package:immich_mobile/utils/licenses.dart';import 'package:immich_mobile/utils/migration.dart';@@ -101,7 +101,7 @@ Future<void> initApp() async {);await FileDownloader().trackTasksInGroup(- downloadGroupLivePhoto,+ kDownloadGroupLivePhoto,markDownloadedComplete: false,);@@ -179,7 +179,7 @@ class ImmichAppState extends ConsumerState<ImmichApp>void _configureFileDownloaderNotifications() {FileDownloader().configureNotificationForGroup(- downloadGroupImage,+ kDownloadGroupImage,running: TaskNotification('downloading_media'.tr(),'${'file_name'.tr()}: {filename}',@@ -192,7 +192,7 @@ class ImmichAppState extends ConsumerState<ImmichApp>);FileDownloader().configureNotificationForGroup(- downloadGroupVideo,+ kDownloadGroupVideo,running: TaskNotification('downloading_media'.tr(),'${'file_name'.tr()}: {filename}',diff --git a/mobile/lib/repositories/download.repository.dart b/mobile/lib/repositories/download.repository.dartindex f1dae3c251..a1ad4ee3d9 100644--- a/mobile/lib/repositories/download.repository.dart+++ b/mobile/lib/repositories/download.repository.dart@@ -4,10 +4,10 @@ import 'dart:io';import 'package:background_downloader/background_downloader.dart';import 'package:collection/collection.dart';import 'package:hooks_riverpod/hooks_riverpod.dart';+import 'package:immich_mobile/constants/constants.dart';import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';import 'package:immich_mobile/models/download/livephotos_medatada.model.dart';import 'package:immich_mobile/services/api.service.dart';-import 'package:immich_mobile/utils/download.dart';import 'package:immich_mobile/utils/image_url_builder.dart';final downloadRepositoryProvider = Provider((ref) => DownloadRepository());@@ -33,19 +33,19 @@ class DownloadRepository {DownloadRepository() {_downloader.registerCallbacks(- group: downloadGroupImage,+ group: kDownloadGroupImage,taskStatusCallback: (update) => onImageDownloadStatus?.call(update),taskProgressCallback: (update) => onTaskProgress?.call(update),);_downloader.registerCallbacks(- group: downloadGroupVideo,+ group: kDownloadGroupVideo,taskStatusCallback: (update) => onVideoDownloadStatus?.call(update),taskProgressCallback: (update) => onTaskProgress?.call(update),);_downloader.registerCallbacks(- group: downloadGroupLivePhoto,+ group: kDownloadGroupLivePhoto,taskStatusCallback: (update) => onLivePhotoDownloadStatus?.call(update),taskProgressCallback: (update) => onTaskProgress?.call(update),);@@ -66,7 +66,7 @@ class DownloadRepository {Future<List<TaskRecord>> getLiveVideoTasks() {return _downloader.database.allRecordsWithStatus(TaskStatus.complete,- group: downloadGroupLivePhoto,+ group: kDownloadGroupLivePhoto,);}@@ -100,7 +100,7 @@ class DownloadRepository {headers: headers,filename: asset.name,updates: Updates.statusAndProgress,- group: isVideo ? downloadGroupVideo : downloadGroupImage,+ group: isVideo ? kDownloadGroupVideo : kDownloadGroupImage,);continue;}@@ -113,7 +113,7 @@ class DownloadRepository {headers: headers,filename: asset.name,updates: Updates.statusAndProgress,- group: downloadGroupLivePhoto,+ group: kDownloadGroupLivePhoto,metaData: json.encode(_dummyMetadata),);@@ -126,7 +126,7 @@ class DownloadRepository {.toUpperCase().replaceAll(RegExp(r"\.(JPG|HEIC)$"), '.MOV'),updates: Updates.statusAndProgress,- group: downloadGroupLivePhoto,+ group: kDownloadGroupLivePhoto,metaData: json.encode(_dummyMetadata),);}diff --git a/mobile/lib/services/download.service.dart b/mobile/lib/services/download.service.dartindex 98f1765d04..fbd3f406fd 100644--- a/mobile/lib/services/download.service.dart+++ b/mobile/lib/services/download.service.dart@@ -3,6 +3,7 @@ import 'dart:io';import 'package:background_downloader/background_downloader.dart';import 'package:flutter/services.dart';import 'package:hooks_riverpod/hooks_riverpod.dart';+import 'package:immich_mobile/constants/constants.dart';import 'package:immich_mobile/domain/models/store.model.dart';import 'package:immich_mobile/entities/asset.entity.dart';import 'package:immich_mobile/entities/store.entity.dart';@@ -10,7 +11,6 @@ import 'package:immich_mobile/models/download/livephotos_medatada.model.dart';import 'package:immich_mobile/repositories/download.repository.dart';import 'package:immich_mobile/repositories/file_media.repository.dart';import 'package:immich_mobile/services/api.service.dart';-import 'package:immich_mobile/utils/download.dart';import 'package:logging/logging.dart';final downloadServiceProvider = Provider(@@ -173,7 +173,7 @@ class DownloadService {_buildDownloadTask(asset.remoteId!,asset.fileName,- group: downloadGroupLivePhoto,+ group: kDownloadGroupLivePhoto,metadata: LivePhotosMetadata(part: LivePhotosPart.image,id: asset.remoteId!,@@ -184,7 +184,7 @@ class DownloadService {asset.fileName.toUpperCase().replaceAll(RegExp(r"\.(JPG|HEIC)$"), '.MOV'),- group: downloadGroupLivePhoto,+ group: kDownloadGroupLivePhoto,metadata: LivePhotosMetadata(part: LivePhotosPart.video,id: asset.remoteId!,@@ -201,7 +201,7 @@ class DownloadService {_buildDownloadTask(asset.remoteId!,asset.fileName,- group: asset.isImage ? downloadGroupImage : downloadGroupVideo,+ group: asset.isImage ? kDownloadGroupImage : kDownloadGroupVideo,),];}diff --git a/mobile/lib/utils/download.dart b/mobile/lib/utils/download.dartdeleted file mode 100644index c701f353a2..0000000000--- a/mobile/lib/utils/download.dart+++ /dev/null@@ -1,3 +0,0 @@-const downloadGroupImage = 'group_image';-const downloadGroupVideo = 'group_video';-const downloadGroupLivePhoto = 'group_livephoto';