mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 11:06:57 +00:00
add ab full check
This commit is contained in:
@@ -241,6 +241,9 @@ class _AddressBookState extends State<AddressBook> {
|
||||
}
|
||||
|
||||
void abAddId() async {
|
||||
if (gFFI.abModel.isFull(true)) {
|
||||
return;
|
||||
}
|
||||
var isInProgress = false;
|
||||
IDTextEditingController idController = IDTextEditingController(text: '');
|
||||
TextEditingController aliasController = TextEditingController(text: '');
|
||||
|
||||
@@ -644,6 +644,9 @@ abstract class BasePeerCard extends StatelessWidget {
|
||||
),
|
||||
proc: () {
|
||||
() async {
|
||||
if (gFFI.abModel.isFull(true)) {
|
||||
return;
|
||||
}
|
||||
if (!gFFI.abModel.idContainBy(peer.id)) {
|
||||
gFFI.abModel.addPeer(peer);
|
||||
await gFFI.abModel.pushAb();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user