new: pull to refresh on server tab

This commit is contained in:
lollipopkit
2023-02-17 15:55:34 +08:00
parent 1aac166c43
commit 99aa0fc1f5
12 changed files with 46 additions and 25 deletions

View File

@@ -41,12 +41,18 @@ class ServerProvider extends BusyProvider {
return Server(spi, initStatus, null, ServerState.disconnected);
}
Future<void> refreshData({ServerPrivateInfo? spi}) async {
Future<void> refreshData(
{ServerPrivateInfo? spi, bool onlyFailed = false}) async {
if (spi != null) {
await _getData(spi);
return;
}
await Future.wait(_servers.map((s) async {
if (onlyFailed) {
if (s.cs != ServerState.failed) return;
_limiter.resetTryTimes(s.spi.id);
}
if (onlyFailed && s.cs != ServerState.failed) return;
await _getData(s.spi);
}));
}
@@ -72,6 +78,7 @@ class ServerProvider extends BusyProvider {
for (var i = 0; i < _servers.length; i++) {
_servers[i].cs = ServerState.disconnected;
}
_limiter.clear();
notifyListeners();
}
@@ -274,4 +281,8 @@ class _TryLimiter {
void resetTryTimes(String id) {
_triedTimes[id] = 0;
}
void clear() {
_triedTimes.clear();
}
}

View File

@@ -2,9 +2,8 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 218;
static const String engine =
"Flutter 3.7.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 9944297138 (5 days ago) • 2023-02-08 15:46:04 -0800\nEngine • revision 248290d6d5\nTools • Dart 2.19.2 • DevTools 2.20.1\n";
static const String buildAt = "2023-02-14 18:46:55.180156";
static const int modifications = 5;
static const int build = 220;
static const String engine = "Flutter 3.7.3 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 9944297138 (7 days ago) • 2023-02-08 15:46:04 -0800\nEngine • revision 248290d6d5\nTools • Dart 2.19.2 • DevTools 2.20.1\n";
static const String buildAt = "2023-02-16 12:58:28.193531";
static const int modifications = 3;
}