mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
opt.
This commit is contained in:
@@ -12,11 +12,22 @@ class Server {
|
||||
}
|
||||
|
||||
enum ServerState {
|
||||
failed,
|
||||
disconnected,
|
||||
connecting,
|
||||
connected,
|
||||
failed;
|
||||
|
||||
bool get shouldConnect =>
|
||||
this == ServerState.disconnected || this == ServerState.failed;
|
||||
/// Connected to server
|
||||
connected,
|
||||
|
||||
/// Status parsing
|
||||
loading,
|
||||
|
||||
/// Status parsing finished
|
||||
finished;
|
||||
|
||||
bool get shouldConnect => this < ServerState.connecting;
|
||||
|
||||
bool get canViewDetails => this == ServerState.finished;
|
||||
|
||||
operator <(ServerState other) => index < other.index;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import '../../store/setting.dart';
|
||||
class TryLimiter {
|
||||
final Map<String, int> _triedTimes = {};
|
||||
|
||||
bool shouldTry(String id) {
|
||||
bool canTry(String id) {
|
||||
final maxCount = locator<SettingStore>().maxRetryCount.fetch()!;
|
||||
if (maxCount <= 0) {
|
||||
return true;
|
||||
@@ -13,10 +13,13 @@ class TryLimiter {
|
||||
if (times >= maxCount) {
|
||||
return false;
|
||||
}
|
||||
_triedTimes[id] = times + 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void inc(String sid) {
|
||||
_triedTimes[sid] = (_triedTimes[sid] ?? 0) + 1;
|
||||
}
|
||||
|
||||
void reset(String id) {
|
||||
_triedTimes[id] = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user