use existing _isBackgroung flag

This commit is contained in:
Neeraj Gupta 2021-09-05 15:48:14 +05:30
parent f16ff8510a
commit df3917c2c8
3 changed files with 7 additions and 7 deletions

View file

@ -161,7 +161,7 @@ Future<void> _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);
}

View file

@ -50,12 +50,12 @@ class LocalSyncService {
PhotoManager.startChangeNotify();
}
Future<void> sync({bool isAppInBackground = false}) async {
Future<void> 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",

View file

@ -74,7 +74,7 @@ class SyncService {
return _existingSync.future;
}
Future<bool> sync({bool isAppInBackground = false}) async {
Future<bool> sync() async {
_syncStopRequested = false;
if (_existingSync != null) {
_logger.warning("Sync already in progress, skipping.");
@ -83,7 +83,7 @@ class SyncService {
_existingSync = Completer<bool>();
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<void> _doSync({bool isAppInBackground = false}) async {
await _localSyncService.sync(isAppInBackground: isAppInBackground);
Future<void> _doSync() async {
await _localSyncService.sync();
if (_localSyncService.hasCompletedFirstImport()) {
await _remoteSyncService.sync();
final shouldSync = await _localSyncService.syncAll();