flutter hide cm if client is empty, close cm if that last for 6 seconds
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
3e6faf8364
commit
50b8744f24
@ -268,10 +268,12 @@ hideCmWindow({bool isStartup = false}) async {
|
|||||||
await windowManager.hide();
|
await windowManager.hide();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await windowManager.setOpacity(0);
|
if (await windowManager.getOpacity() != 0) {
|
||||||
bind.mainHideDocker();
|
await windowManager.setOpacity(0);
|
||||||
await windowManager.minimize();
|
bind.mainHideDocker();
|
||||||
await windowManager.hide();
|
await windowManager.minimize();
|
||||||
|
await windowManager.hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
String _verificationMethod = "";
|
String _verificationMethod = "";
|
||||||
String _temporaryPasswordLength = "";
|
String _temporaryPasswordLength = "";
|
||||||
String _approveMode = "";
|
String _approveMode = "";
|
||||||
|
int _zeroClientLengthCounter = 0;
|
||||||
|
|
||||||
late String _emptyIdShow;
|
late String _emptyIdShow;
|
||||||
late final IDTextEditingController _serverId;
|
late final IDTextEditingController _serverId;
|
||||||
@ -120,6 +121,17 @@ class ServerModel with ChangeNotifier {
|
|||||||
_emptyIdShow = translate("Generating ...");
|
_emptyIdShow = translate("Generating ...");
|
||||||
_serverId = IDTextEditingController(text: _emptyIdShow);
|
_serverId = IDTextEditingController(text: _emptyIdShow);
|
||||||
|
|
||||||
|
// initital _hideCm at startup
|
||||||
|
final verificationMethod =
|
||||||
|
bind.mainGetOptionSync(key: "verification-method");
|
||||||
|
final approveMode = bind.mainGetOptionSync(key: 'approve-mode');
|
||||||
|
_hideCm = option2bool(
|
||||||
|
'allow-hide-cm', bind.mainGetOptionSync(key: 'allow-hide-cm'));
|
||||||
|
if (!(approveMode == 'password' &&
|
||||||
|
verificationMethod == kUsePermanentPassword)) {
|
||||||
|
_hideCm = false;
|
||||||
|
}
|
||||||
|
|
||||||
timerCallback() async {
|
timerCallback() async {
|
||||||
final connectionStatus =
|
final connectionStatus =
|
||||||
jsonDecode(await bind.mainGetConnectStatus()) as Map<String, dynamic>;
|
jsonDecode(await bind.mainGetConnectStatus()) as Map<String, dynamic>;
|
||||||
@ -134,6 +146,17 @@ class ServerModel with ChangeNotifier {
|
|||||||
if (res != null) {
|
if (res != null) {
|
||||||
debugPrint("clients not match!");
|
debugPrint("clients not match!");
|
||||||
updateClientState(res);
|
updateClientState(res);
|
||||||
|
} else {
|
||||||
|
if (_clients.isEmpty) {
|
||||||
|
hideCmWindow();
|
||||||
|
if (_zeroClientLengthCounter++ == 12) {
|
||||||
|
// 6 second
|
||||||
|
windowManager.close();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_zeroClientLengthCounter = 0;
|
||||||
|
if (!_hideCm) showCmWindow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,6 +445,7 @@ class ServerModel with ChangeNotifier {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final oldClientLenght = _clients.length;
|
||||||
_clients.clear();
|
_clients.clear();
|
||||||
tabController.state.value.tabs.clear();
|
tabController.state.value.tabs.clear();
|
||||||
|
|
||||||
@ -434,6 +458,16 @@ class ServerModel with ChangeNotifier {
|
|||||||
debugPrint("Failed to decode clientJson '$clientJson', error $e");
|
debugPrint("Failed to decode clientJson '$clientJson', error $e");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (desktopType == DesktopType.cm) {
|
||||||
|
if (_clients.isEmpty) {
|
||||||
|
hideCmWindow();
|
||||||
|
} else if (!_hideCm) {
|
||||||
|
showCmWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_clients.length != oldClientLenght) {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addConnection(Map<String, dynamic> evt) {
|
void addConnection(Map<String, dynamic> evt) {
|
||||||
@ -461,6 +495,9 @@ class ServerModel with ChangeNotifier {
|
|||||||
_clients.removeAt(index_disconnected);
|
_clients.removeAt(index_disconnected);
|
||||||
tabController.remove(index_disconnected);
|
tabController.remove(index_disconnected);
|
||||||
}
|
}
|
||||||
|
if (desktopType == DesktopType.cm && !_hideCm) {
|
||||||
|
showCmWindow();
|
||||||
|
}
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
if (isAndroid && !client.authorized) showLoginDialog(client);
|
if (isAndroid && !client.authorized) showLoginDialog(client);
|
||||||
@ -581,6 +618,9 @@ class ServerModel with ChangeNotifier {
|
|||||||
parent.target?.dialogManager.dismissByTag(getLoginDialogTag(id));
|
parent.target?.dialogManager.dismissByTag(getLoginDialogTag(id));
|
||||||
parent.target?.invokeMethod("cancel_notification", id);
|
parent.target?.invokeMethod("cancel_notification", id);
|
||||||
}
|
}
|
||||||
|
if (desktopType == DesktopType.cm && _clients.isEmpty) {
|
||||||
|
hideCmWindow();
|
||||||
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint("onClientRemove failed,error:$e");
|
debugPrint("onClientRemove failed,error:$e");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user