Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mobile][photos] Skip the startup sync in an iOS main engine launched in the background

laurenspriem07851d31ca9d
diff --git a/mobile/apps/photos/lib/main.dart b/mobile/apps/photos/lib/main.dart
index 6cdf0f81f8..9caafd3008 100644
--- a/mobile/apps/photos/lib/main.dart
+++ b/mobile/apps/photos/lib/main.dart
@@ -710,20 +710,15 @@ Future<void> _homeWidgetSyncPeriodic() async {
}
Future<void> _scheduleFGSync(String caller) async {
- await _sync(caller);
- _scheduleNextFGSync();
-}
-
-void _scheduleNextFGSync() {
+ final bool isIOSWokenInBackground =
+ Platform.isIOS &&
+ WidgetsBinding.instance.lifecycleState != AppLifecycleState.resumed;
+ if (isIOSWokenInBackground) {
+ _logger.info("Skipping $caller sync, app is not resumed");
+ } else {
+ await _sync(caller);
+ }
Future.delayed(kFGSyncFrequency, () async {
- final bool isIOSWokenInBackground =
- Platform.isIOS &&
- WidgetsBinding.instance.lifecycleState != AppLifecycleState.resumed;
- if (isIOSWokenInBackground) {
- _logger.info("Skipping fgSyncCron, app is not resumed");
- _scheduleNextFGSync();
- return;
- }
unawaited(_scheduleFGSync('fgSyncCron'));
});
}