diff --git a/lib/services/sync/sync_manager.dart b/lib/services/sync/sync_manager.dart index 1b9fd14..70f1f6a 100644 --- a/lib/services/sync/sync_manager.dart +++ b/lib/services/sync/sync_manager.dart @@ -7,26 +7,22 @@ import 'sync_provider.dart'; /// Central provider-agnostic synchronization coordinator. /// -/// Sync work is persisted in [SyncOutbox]. The manager also reconciles on -/// startup, app resume, and periodically while the app is foregrounded so a -/// ride recorded offline is automatically retried after connectivity returns. +/// Sync work is persisted in [SyncOutbox]. The manager reconciles persisted +/// work on startup and whenever the app returns to the foreground. Network +/// failures remain queued instead of being discarded. class SyncManager extends ChangeNotifier with WidgetsBindingObserver { final SyncOutbox _outbox; final Map _providers = {}; String _activeProviderId = 'fake'; bool _isProcessing = false; DateTime? Function() _nowProvider; - Timer? _foregroundRetryTimer; SyncManager(this._outbox, {List? initialProviders, String? defaultProviderId, DateTime? Function()? nowProvider}) : _nowProvider = nowProvider ?? (() => DateTime.now()) { if (initialProviders != null) { - for (final p in initialProviders) { - registerProvider(p); - } + for (final p in initialProviders) registerProvider(p); } if (defaultProviderId != null) _activeProviderId = defaultProviderId; WidgetsBinding.instance.addObserver(this); - _foregroundRetryTimer = Timer.periodic(const Duration(seconds: 30), (_) => unawaited(processQueue())); unawaited(processQueue()); } @@ -102,9 +98,7 @@ class SyncManager extends ChangeNotifier with WidgetsBindingObserver { @override void didChangeAppLifecycleState(AppLifecycleState state) { - if (state == AppLifecycleState.resumed) { - unawaited(processQueue()); - } + if (state == AppLifecycleState.resumed) unawaited(processQueue()); } Future processQueue() async { @@ -170,7 +164,6 @@ class SyncManager extends ChangeNotifier with WidgetsBindingObserver { @override void dispose() { - _foregroundRetryTimer?.cancel(); WidgetsBinding.instance.removeObserver(this); super.dispose(); }