Browse Source

Trigger local sync after downloading a file

ashilkn 2 years ago
parent
commit
0b378c824e
2 changed files with 15 additions and 9 deletions
  1. 13 9
      lib/services/local_sync_service.dart
  2. 2 0
      lib/ui/viewer/file/fading_app_bar.dart

+ 13 - 9
lib/services/local_sync_service.dart

@@ -376,16 +376,20 @@ class LocalSyncService {
     // In case of iOS limit permission, this call back is fired immediately
     // after file selection dialog is dismissed.
     PhotoManager.addChangeCallback((value) async {
-      _logger.info("Something changed on disk");
-      if (_existingSync != null) {
-        await _existingSync.future;
-      }
-      if (hasGrantedLimitedPermissions()) {
-        syncAll();
-      } else {
-        sync().then((value) => _refreshDeviceFolderCountAndCover());
-      }
+      checkAndSync();
     });
     PhotoManager.startChangeNotify();
   }
+
+  Future<void> checkAndSync() async {
+    _logger.info("Something changed on disk");
+    if (_existingSync != null) {
+      await _existingSync.future;
+    }
+    if (hasGrantedLimitedPermissions()) {
+      syncAll();
+    } else {
+      sync().then((value) => _refreshDeviceFolderCountAndCover());
+    }
+  }
 }

+ 2 - 0
lib/ui/viewer/file/fading_app_bar.dart

@@ -23,6 +23,7 @@ import 'package:photos/services/collections_service.dart';
 import 'package:photos/services/favorites_service.dart';
 import 'package:photos/services/hidden_service.dart';
 import 'package:photos/services/ignored_files_service.dart';
+import 'package:photos/services/local_sync_service.dart';
 import 'package:photos/ui/common/progress_dialog.dart';
 import 'package:photos/ui/create_collection_page.dart';
 import 'package:photos/ui/viewer/file/custom_app_bar.dart';
@@ -464,6 +465,7 @@ class FadingAppBarState extends State<FadingAppBar> {
       showGenericErrorDialog(context: context);
     } finally {
       PhotoManager.startChangeNotify();
+      LocalSyncService.instance.checkAndSync();
     }
   }