opt: optimize cm ui & timer & auto close

Signed-off-by: Kingtous <kingtous@qq.com>
This commit is contained in:
Kingtous
2022-08-18 00:34:04 +08:00
parent a580b98472
commit eed87808e5
5 changed files with 104 additions and 49 deletions

View File

@@ -342,6 +342,10 @@ class ServerModel with ChangeNotifier {
var res = await bind.mainGetClientsState();
try {
final List clientsJson = jsonDecode(res);
if (isDesktop && clientsJson.isEmpty && _clients.isNotEmpty) {
// exit cm when >1 peers to no peers
exit(0);
}
_clients.clear();
for (var clientJson in clientsJson) {
final client = Client.fromJson(clientJson);