diff --git a/cyberwow/lib/controller/refresh.dart b/cyberwow/lib/controller/refresh.dart index 98b1fd8..300e7d0 100644 --- a/cyberwow/lib/controller/refresh.dart +++ b/cyberwow/lib/controller/refresh.dart @@ -32,7 +32,7 @@ Stream targetHeight(GetNotificationFunc getNotification) async* { if (_appState == AppLifecycleState.resumed) { final _targetHeight = await rpc.targetHeight(); - yield _targetHeight + yield _targetHeight; } await Future.delayed(const Duration(seconds: 2), () => "1"); diff --git a/cyberwow/lib/state.dart b/cyberwow/lib/state.dart index deee380..5106b01 100644 --- a/cyberwow/lib/state.dart +++ b/cyberwow/lib/state.dart @@ -178,17 +178,8 @@ class SyncedState extends HookedState { Future next() async { print("Synced next"); - while (true) { - final _appState = getNotification(); - // print('synced: app state: ${_appState}'); - - if (_appState == AppLifecycleState.resumed) { - final _targetHeight = await rpc.targetHeight(); - if (_targetHeight > 0) break; - height = await rpc.height(); - } - - await Future.delayed(const Duration(seconds: 2), () => "1"); + await for (var _targetHeight in refresh.targetHeight(getNotification)) { + if (_targetHeight > 0) break; } // print('synced: loop exit');