diff --git a/lib/main.dart b/lib/main.dart index d8d170ee0..e404923d0 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -161,7 +161,7 @@ Future _sync({bool isAppInBackground = false}) async { _logger.info("Syncing in background"); } try { - await SyncService.instance.sync(isAppInBackground: isAppInBackground); + await SyncService.instance.sync(); } catch (e, s) { _logger.severe("Sync error", e, s); } diff --git a/lib/services/local_sync_service.dart b/lib/services/local_sync_service.dart index 7294f2e3e..e8c48ec67 100644 --- a/lib/services/local_sync_service.dart +++ b/lib/services/local_sync_service.dart @@ -50,12 +50,12 @@ class LocalSyncService { PhotoManager.startChangeNotify(); } - Future sync({bool isAppInBackground = false}) async { + Future sync() async { if (!_prefs.containsKey(kHasGrantedPermissionsKey)) { _logger.info("Skipping local sync since permission has not been granted"); return; } - if (Platform.isAndroid && !isAppInBackground) { + if (Platform.isAndroid && !_isBackground) { final permissionState = await PhotoManager.requestPermissionExtend(); if (permissionState != PermissionState.authorized) { _logger.severe("sync requested with invalid permission", diff --git a/lib/services/sync_service.dart b/lib/services/sync_service.dart index 04c2eb557..309fe30c1 100644 --- a/lib/services/sync_service.dart +++ b/lib/services/sync_service.dart @@ -74,7 +74,7 @@ class SyncService { return _existingSync.future; } - Future sync({bool isAppInBackground = false}) async { + Future sync() async { _syncStopRequested = false; if (_existingSync != null) { _logger.warning("Sync already in progress, skipping."); @@ -83,7 +83,7 @@ class SyncService { _existingSync = Completer(); bool successful = false; try { - await _doSync(isAppInBackground: isAppInBackground); + await _doSync(); if (_lastSyncStatusEvent != null && _lastSyncStatusEvent.status != SyncStatus.completed_first_gallery_import && @@ -209,8 +209,8 @@ class SyncService { } } - Future _doSync({bool isAppInBackground = false}) async { - await _localSyncService.sync(isAppInBackground: isAppInBackground); + Future _doSync() async { + await _localSyncService.sync(); if (_localSyncService.hasCompletedFirstImport()) { await _remoteSyncService.sync(); final shouldSync = await _localSyncService.syncAll();