This commit is contained in:
lollipopkit
2023-12-11 11:13:49 +08:00
parent 73752bffc3
commit ce9929e93f
6 changed files with 23 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:toolbox/core/utils/platform/path.dart';
import 'package:toolbox/data/model/app/shell_func.dart';
import 'package:toolbox/data/model/server/system.dart';
@@ -135,10 +136,13 @@ class ServerProvider extends ChangeNotifier {
return await _getData(s.spi);
}
static final refreshKey = GlobalKey<RefreshIndicatorState>();
Future<void> startAutoRefresh() async {
final duration = Stores.setting.serverStatusUpdateInterval.fetch();
stopAutoRefresh();
if (duration == 0) return;
refreshKey.currentState?.show();
_timer = Timer.periodic(Duration(seconds: duration), (_) async {
await refreshData();
});
@@ -151,6 +155,16 @@ class ServerProvider extends ChangeNotifier {
}
}
void setNotBusy([String? id]) {
if (id == null) {
for (final s in _servers.values) {
s.isBusy = false;
}
return;
}
_servers[id]?.isBusy = false;
}
bool get isAutoRefreshOn => _timer != null;
void setDisconnected() {