add ab full check

This commit is contained in:
rustdesk
2023-07-26 20:43:18 +08:00
parent 4fe85cdd4a
commit 791645fa59
38 changed files with 124 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ class AbModel {
final selectedTags = List<String>.empty(growable: true).obs;
var initialized = false;
var licensedDevices = 0;
WeakReference<FFI> parent;
@@ -52,6 +53,10 @@ class AbModel {
if (json.containsKey('error')) {
abError.value = json['error'];
} else if (json.containsKey('data')) {
try {
gFFI.abModel.licensedDevices = json['licensed_devices'];
// ignore: empty_catches
} catch (e) {}
final data = jsonDecode(json['data']);
if (data != null) {
tags.clear();
@@ -94,6 +99,15 @@ class AbModel {
peers.add(peer);
}
bool isFull(bool warn) {
final res = licensedDevices > 0 && peers.length >= licensedDevices;
if (res && warn) {
BotToast.showText(
contentColor: Colors.red, text: translate("exceed_max_devices"));
}
return res;
}
void addPeer(Peer peer) {
peers.removeWhere((e) => e.id == peer.id);
peers.add(peer);