diff --git a/flutter/lib/common/widgets/address_book.dart b/flutter/lib/common/widgets/address_book.dart index a827df57..c62a8842 100644 --- a/flutter/lib/common/widgets/address_book.dart +++ b/flutter/lib/common/widgets/address_book.dart @@ -241,6 +241,9 @@ class _AddressBookState extends State { } void abAddId() async { + if (gFFI.abModel.isFull(true)) { + return; + } var isInProgress = false; IDTextEditingController idController = IDTextEditingController(text: ''); TextEditingController aliasController = TextEditingController(text: ''); diff --git a/flutter/lib/common/widgets/peer_card.dart b/flutter/lib/common/widgets/peer_card.dart index 09d1cb52..a7345404 100644 --- a/flutter/lib/common/widgets/peer_card.dart +++ b/flutter/lib/common/widgets/peer_card.dart @@ -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(); diff --git a/flutter/lib/models/ab_model.dart b/flutter/lib/models/ab_model.dart index 72f1438b..ee16fb79 100644 --- a/flutter/lib/models/ab_model.dart +++ b/flutter/lib/models/ab_model.dart @@ -29,6 +29,7 @@ class AbModel { final selectedTags = List.empty(growable: true).obs; var initialized = false; + var licensedDevices = 0; WeakReference 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); diff --git a/src/lang/ca.rs b/src/lang/ca.rs index fdacb2f4..51a731c3 100644 --- a/src/lang/ca.rs +++ b/src/lang/ca.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/cn.rs b/src/lang/cn.rs index d0c5e7be..d15c21d4 100644 --- a/src/lang/cn.rs +++ b/src/lang/cn.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/cs.rs b/src/lang/cs.rs index 084adaaa..29898eaf 100644 --- a/src/lang/cs.rs +++ b/src/lang/cs.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/da.rs b/src/lang/da.rs index 129c2251..0a4adaf3 100644 --- a/src/lang/da.rs +++ b/src/lang/da.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/de.rs b/src/lang/de.rs index 8d106a7d..c730852d 100644 --- a/src/lang/de.rs +++ b/src/lang/de.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/el.rs b/src/lang/el.rs index 5794a080..eb91e9a8 100644 --- a/src/lang/el.rs +++ b/src/lang/el.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/en.rs b/src/lang/en.rs index ecaffa0d..001d9133 100644 --- a/src/lang/en.rs +++ b/src/lang/en.rs @@ -71,6 +71,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("resolution_custom_tip", "Custom resolution"), ("accept_and_elevate_btn_tooltip", "Accept the connection and elevate UAC permissions."), ("clipboard_wait_response_timeout_tip", "Timed out waiting for copy response."), - ("logout_tip", "Are you sure you want to log out?") + ("logout_tip", "Are you sure you want to log out?"), + ("exceed_max_devices", "You have reached the maximum number of managed devices."), ].iter().cloned().collect(); } diff --git a/src/lang/eo.rs b/src/lang/eo.rs index 5f3c4e7d..a576538e 100644 --- a/src/lang/eo.rs +++ b/src/lang/eo.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/es.rs b/src/lang/es.rs index e53bd4ff..f953bd9c 100644 --- a/src/lang/es.rs +++ b/src/lang/es.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/fa.rs b/src/lang/fa.rs index 6ad33256..112edf32 100644 --- a/src/lang/fa.rs +++ b/src/lang/fa.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/fr.rs b/src/lang/fr.rs index 09e048d3..57c548e0 100644 --- a/src/lang/fr.rs +++ b/src/lang/fr.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/hu.rs b/src/lang/hu.rs index a963c183..638ed3ad 100644 --- a/src/lang/hu.rs +++ b/src/lang/hu.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/id.rs b/src/lang/id.rs index dfa6d380..ac9df01b 100644 --- a/src/lang/id.rs +++ b/src/lang/id.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/it.rs b/src/lang/it.rs index c3209ddc..6822be40 100644 --- a/src/lang/it.rs +++ b/src/lang/it.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", "Servizio"), ("Start", "Avvia"), ("Stop", "Ferma"), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ja.rs b/src/lang/ja.rs index c326e44f..67234039 100644 --- a/src/lang/ja.rs +++ b/src/lang/ja.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ko.rs b/src/lang/ko.rs index 3b56a69b..c0b71c20 100644 --- a/src/lang/ko.rs +++ b/src/lang/ko.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/kz.rs b/src/lang/kz.rs index 9f1287dc..829c59c7 100644 --- a/src/lang/kz.rs +++ b/src/lang/kz.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/lt.rs b/src/lang/lt.rs index b95ac600..69936b2b 100644 --- a/src/lang/lt.rs +++ b/src/lang/lt.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/nl.rs b/src/lang/nl.rs index 6c88ffb7..92bd7fd1 100644 --- a/src/lang/nl.rs +++ b/src/lang/nl.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/pl.rs b/src/lang/pl.rs index 89271b5e..af6d1165 100644 --- a/src/lang/pl.rs +++ b/src/lang/pl.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/pt_PT.rs b/src/lang/pt_PT.rs index 6f1b3a5a..52675daf 100644 --- a/src/lang/pt_PT.rs +++ b/src/lang/pt_PT.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ptbr.rs b/src/lang/ptbr.rs index f59a5ea2..195b7980 100644 --- a/src/lang/ptbr.rs +++ b/src/lang/ptbr.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ro.rs b/src/lang/ro.rs index 6f326442..378d7c03 100644 --- a/src/lang/ro.rs +++ b/src/lang/ro.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ru.rs b/src/lang/ru.rs index 9b4b65b3..3af5ba4b 100644 --- a/src/lang/ru.rs +++ b/src/lang/ru.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", "Сервис"), ("Start", "Запустить"), ("Stop", "Остановить"), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sk.rs b/src/lang/sk.rs index c7a2c742..f24f55be 100644 --- a/src/lang/sk.rs +++ b/src/lang/sk.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sl.rs b/src/lang/sl.rs index d08afcf0..ff5c254e 100755 --- a/src/lang/sl.rs +++ b/src/lang/sl.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sq.rs b/src/lang/sq.rs index 4c893437..79732813 100644 --- a/src/lang/sq.rs +++ b/src/lang/sq.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sr.rs b/src/lang/sr.rs index 6c16abbe..3bb40f4c 100644 --- a/src/lang/sr.rs +++ b/src/lang/sr.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/sv.rs b/src/lang/sv.rs index 1df13f95..ac898e38 100644 --- a/src/lang/sv.rs +++ b/src/lang/sv.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/template.rs b/src/lang/template.rs index d1f2f23b..5c710624 100644 --- a/src/lang/template.rs +++ b/src/lang/template.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/th.rs b/src/lang/th.rs index f3c629b2..2b2d0f4b 100644 --- a/src/lang/th.rs +++ b/src/lang/th.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/tr.rs b/src/lang/tr.rs index 4e2c6def..d7bd99f2 100644 --- a/src/lang/tr.rs +++ b/src/lang/tr.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/tw.rs b/src/lang/tw.rs index df1dbcd2..bef733f0 100644 --- a/src/lang/tw.rs +++ b/src/lang/tw.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/ua.rs b/src/lang/ua.rs index f8f0a8fe..3b115a5f 100644 --- a/src/lang/ua.rs +++ b/src/lang/ua.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); } diff --git a/src/lang/vn.rs b/src/lang/vn.rs index 458fbba1..59490da1 100644 --- a/src/lang/vn.rs +++ b/src/lang/vn.rs @@ -521,5 +521,8 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Service", ""), ("Start", ""), ("Stop", ""), + ("exceed_max_devices", ""), + ("Sync with recent sessions", ""), + ("Sort tags", ""), ].iter().cloned().collect(); }