From 35a31eec35c2105a1c9b1987712dc271a88d1943 Mon Sep 17 00:00:00 2001 From: fuwa Date: Tue, 23 Jul 2019 07:25:01 +0800 Subject: [PATCH] refresh faster while in foreground --- cyberwow/lib/controller/refresh.dart | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/cyberwow/lib/controller/refresh.dart b/cyberwow/lib/controller/refresh.dart index fbc0cd3..c0d84c2 100644 --- a/cyberwow/lib/controller/refresh.dart +++ b/cyberwow/lib/controller/refresh.dart @@ -29,20 +29,6 @@ import '../config.dart'; typedef GetNotificationFunc = AppLifecycleState Function(); -Stream targetHeight(GetNotificationFunc getNotification) async* { - while (true) { - final _appState = getNotification(); - // print('refresh targetHeight: app state: ${_appState}'); - - if (_appState == AppLifecycleState.resumed) { - final _targetHeight = await rpc.targetHeight(); - yield _targetHeight; - } - - await Future.delayed(const Duration(seconds: 2), () => "1"); - } -} - Stream pull(GetNotificationFunc getNotification) async* { while (true) { final _appState = getNotification(); @@ -50,8 +36,9 @@ Stream pull(GetNotificationFunc getNotification) async* { if (_appState == AppLifecycleState.resumed) { yield null; + await Future.delayed(const Duration(milliseconds: 400), () => null); + } else { + await Future.delayed(const Duration(seconds: 2), () => null); } - - await Future.delayed(const Duration(seconds: 2), () => "1"); } }