diff --git a/app/lib/common/providers/notifiers/sync_notifier.dart b/app/lib/common/providers/notifiers/sync_notifier.dart index dd5be9bd287f..7283b6d7ed29 100644 --- a/app/lib/common/providers/notifiers/sync_notifier.dart +++ b/app/lib/common/providers/notifiers/sync_notifier.dart @@ -5,9 +5,12 @@ import 'package:acter/common/extensions/options.dart'; import 'package:acter/common/models/sync_state/sync_state.dart'; import 'package:acter/features/home/providers/client_providers.dart'; import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart' as ffi; +import 'package:logging/logging.dart'; import 'package:riverpod/riverpod.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; +final _log = Logger('a3::common::sync_notifier'); + // ignore_for_file: avoid_print class SyncNotifier extends Notifier { late ffi.Client client; @@ -23,7 +26,7 @@ class SyncNotifier extends Notifier { @override SyncState build() { _providerSubscription = ref.listen>( - alwaysClientProvider, + clientProvider, (AsyncValue? oldVal, AsyncValue newVal) { final newClient = newVal.valueOrNull; if (newClient == null) { @@ -36,10 +39,10 @@ class SyncNotifier extends Notifier { // hack unfortunately means we have two wait a bit but that means // we get past the threshold where it is okay to schedule... client = newClient; - Future.delayed( - const Duration(milliseconds: 1500), - () => _restartSync(), - ); + Future.delayed(const Duration(milliseconds: 1500), () { + _log.info('**************** _restartSync 1 *****************'); + _restartSync(); + }); }, fireImmediately: true, ); @@ -51,13 +54,17 @@ class SyncNotifier extends Notifier { state.countDown.map( (countDown) { if (countDown == 0) { + _log.info('**************** _restartSync 2 *****************'); _restartSync(); } else { // just count down. state = state.copyWith(countDown: countDown - 1); } }, - orElse: () => _restartSync(), + orElse: () { + _log.info('**************** _restartSync 3 *****************'); + _restartSync(); + }, ); } @@ -69,6 +76,7 @@ class SyncNotifier extends Notifier { _syncPoller?.cancel(); _errorPoller?.cancel(); + _log.info('================= startSync ===================='); final sync = syncState = client.startSync(); _syncListener = sync.firstSyncedRx(); // keep it resident in memory