use existing _isBackgroung flag
This commit is contained in:
parent
f16ff8510a
commit
df3917c2c8
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue