Improve.
- make the refresh interval setting makes effect immediately. - auto stop/restart status update when app goto background/resume
This commit is contained in:
@@ -23,6 +23,8 @@ class ServerProvider extends BusyProvider {
|
||||
List<ServerInfo> _servers = [];
|
||||
List<ServerInfo> get servers => _servers;
|
||||
|
||||
Timer? _timer;
|
||||
|
||||
final logger = Logger('ServerProvider');
|
||||
|
||||
Memory get emptyMemory =>
|
||||
@@ -95,11 +97,19 @@ class ServerProvider extends BusyProvider {
|
||||
final duration =
|
||||
locator<SettingStore>().serverStatusUpdateInterval.fetch()!;
|
||||
if (duration == 0) return;
|
||||
Timer.periodic(Duration(seconds: duration), (_) async {
|
||||
stopAutoRefresh();
|
||||
_timer = Timer.periodic(Duration(seconds: duration), (_) async {
|
||||
await refreshData();
|
||||
});
|
||||
}
|
||||
|
||||
void stopAutoRefresh() {
|
||||
if (_timer != null) {
|
||||
_timer!.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
void addServer(ServerPrivateInfo info) {
|
||||
_servers.add(genInfo(info));
|
||||
locator<ServerStore>().put(info);
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ToolBox";
|
||||
static const int build = 65;
|
||||
static const int build = 68;
|
||||
static const String engine =
|
||||
"Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 77d935af4d (2 weeks ago) • 2021-12-16 08:37:33 -0800\nEngine • revision 890a5fca2e\nTools • Dart 2.15.1\n";
|
||||
static const String buildAt = "2021-12-31 15:55:47.350456";
|
||||
static const int modifications = 7;
|
||||
static const String buildAt = "2022-01-02 14:53:09.769990";
|
||||
static const int modifications = 3;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user