High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix(download): handle completed downloads and refresh albums (#20241)
Peter Ombodi86d31d7d2915
diff --git a/mobile/lib/providers/infrastructure/action.provider.dart b/mobile/lib/providers/infrastructure/action.provider.dartindex 69c0532303..80e27b5970 100644--- a/mobile/lib/providers/infrastructure/action.provider.dart+++ b/mobile/lib/providers/infrastructure/action.provider.dart@@ -1,10 +1,13 @@+import 'package:background_downloader/background_downloader.dart';import 'package:flutter/material.dart';import 'package:immich_mobile/constants/enums.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/providers/infrastructure/asset_viewer/current_asset.provider.dart';import 'package:immich_mobile/providers/timeline/multiselect.provider.dart';import 'package:immich_mobile/providers/user.provider.dart';import 'package:immich_mobile/services/action.service.dart';+import 'package:immich_mobile/services/download.service.dart';import 'package:immich_mobile/services/timeline.service.dart';import 'package:immich_mobile/services/upload.service.dart';import 'package:logging/logging.dart';@@ -30,6 +33,7 @@ class ActionNotifier extends Notifier<void> {final Logger _logger = Logger('ActionNotifier');late ActionService _service;late UploadService _uploadService;+ late DownloadService _downloadService;ActionNotifier() : super();@@ -37,6 +41,29 @@ class ActionNotifier extends Notifier<void> {void build() {_uploadService = ref.watch(uploadServiceProvider);_service = ref.watch(actionServiceProvider);+ _downloadService = ref.watch(downloadServiceProvider);+ _downloadService.onImageDownloadStatus = _downloadImageCallback;+ _downloadService.onVideoDownloadStatus = _downloadVideoCallback;+ _downloadService.onLivePhotoDownloadStatus = _downloadLivePhotoCallback;+ }++ void _downloadImageCallback(TaskStatusUpdate update) {+ if (update.status == TaskStatus.complete) {+ _downloadService.saveImageWithPath(update.task);+ }+ }++ void _downloadVideoCallback(TaskStatusUpdate update) {+ if (update.status == TaskStatus.complete) {+ _downloadService.saveVideo(update.task);+ }+ }++ void _downloadLivePhotoCallback(TaskStatusUpdate update) async {+ if (update.status == TaskStatus.complete) {+ final livePhotosId = LivePhotosMetadata.fromJson(update.task.metaData).id;+ _downloadService.saveLivePhotos(update.task, livePhotosId);+ }}List<String> _getRemoteIdsForSource(ActionSource source) {