diff --git a/flutter/lib/common/widgets/address_book.dart b/flutter/lib/common/widgets/address_book.dart index a827df572..c62a88421 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 09d1cb521..a73454040 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 72f1438bc..ee16fb798 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 fdacb2f4e..51a731c35 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 d0c5e7bef..d15c21d4b 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 084adaaaf..29898eaf7 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 129c2251f..0a4adaf36 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 8d106a7df..c730852d5 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 5794a0803..eb91e9a83 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 ecaffa0d0..001d9133d 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 5f3c4e7db..a576538ef 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 e53bd4ff9..f953bd9ce 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 6ad33256c..112edf32a 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 09e048d3a..57c548e08 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 a963c1836..638ed3adf 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 dfa6d380d..ac9df01b3 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 c3209ddcd..6822be403 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 c326e44f3..67234039d 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 3b56a69be..c0b71c205 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 9f1287dc1..829c59c73 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 b95ac6000..69936b2b4 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 6c88ffb76..92bd7fd1f 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 89271b5ec..af6d11659 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 6f1b3a5ac..52675daf7 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 f59a5ea20..195b79804 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 6f326442c..378d7c035 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 9b4b65b36..3af5ba4b6 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 c7a2c7421..f24f55bef 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 d08afcf08..ff5c254e0 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 4c893437e..797328139 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 6c16abbe7..3bb40f4ce 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 1df13f952..ac898e38f 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 d1f2f23bb..5c710624f 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 f3c629b2a..2b2d0f4b2 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 4e2c6defc..d7bd99f25 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 df1dbcd2c..bef733f00 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 f8f0a8fed..3b115a5f3 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 458fbba1c..59490da1d 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(); }