Merge pull request #1969 from fufesou/fix_cm

Fix cm
This commit is contained in:
RustDesk
2022-11-05 11:00:08 +08:00
committed by GitHub
6 changed files with 35 additions and 30 deletions

View File

@@ -32,6 +32,7 @@ class ChatModel with ChangeNotifier {
OverlayState? _overlayState;
OverlayEntry? chatIconOverlayEntry;
OverlayEntry? chatWindowOverlayEntry;
bool isConnManager = false;
final ChatUser me = ChatUser(
id: "",
@@ -42,13 +43,13 @@ class ChatModel with ChangeNotifier {
MessageBody(me, []);
var _currentID = clientModeID;
late bool _isShowChatPage = false;
late bool _isShowCMChatPage = false;
Map<int, MessageBody> get messages => _messages;
int get currentID => _currentID;
bool get isShowChatPage => _isShowChatPage;
bool get isShowCMChatPage => _isShowCMChatPage;
final WeakReference<FFI> parent;
@@ -147,9 +148,11 @@ class ChatModel with ChangeNotifier {
}
}
_isChatOverlayHide() => ((!isDesktop && chatIconOverlayEntry == null) ||
chatWindowOverlayEntry == null);
toggleChatOverlay() {
if ((!isDesktop && chatIconOverlayEntry == null) ||
chatWindowOverlayEntry == null) {
if (_isChatOverlayHide()) {
gFFI.invokeMethod("enable_soft_keyboard", true);
if (!isDesktop) {
showChatIconOverlay();
@@ -161,20 +164,29 @@ class ChatModel with ChangeNotifier {
}
}
showChatPage(int id) async {
if (isConnManager) {
if (!_isShowCMChatPage) {
await toggleCMChatPage(id);
}
} else {
if (_isChatOverlayHide()) {
await toggleChatOverlay();
}
}
}
toggleCMChatPage(int id) async {
if (gFFI.chatModel.currentID != id) {
gFFI.chatModel.changeCurrentID(id);
}
if (_isShowChatPage) {
_isShowChatPage = !_isShowChatPage;
if (_isShowCMChatPage) {
_isShowCMChatPage = !_isShowCMChatPage;
notifyListeners();
await windowManager.setSize(Size(300, 400));
await windowManager.setAlignment(Alignment.topRight);
await windowManager.setSizeAlignment(Size(300, 400), Alignment.topRight);
} else {
await windowManager.setSize(Size(600, 400));
await Future.delayed(Duration(milliseconds: 100));
await windowManager.setAlignment(Alignment.topRight);
_isShowChatPage = !_isShowChatPage;
await windowManager.setSizeAlignment(Size(600, 400), Alignment.topRight);
_isShowCMChatPage = !_isShowCMChatPage;
notifyListeners();
}
}
@@ -208,13 +220,11 @@ class ChatModel with ChangeNotifier {
}
if (text.isEmpty) return;
// mobile: first message show overlay icon
if (chatIconOverlayEntry == null) {
if (!isDesktop && chatIconOverlayEntry == null) {
showChatIconOverlay();
}
// desktop: show chat page
if (!_isShowChatPage) {
toggleCMChatPage(id);
}
// show chat page
await showChatPage(id);
int toId = currentID;

View File

@@ -407,9 +407,7 @@ class ServerModel with ChangeNotifier {
if (client.hasUnreadChatMessage.value) {
client.hasUnreadChatMessage.value = false;
final chatModel = parent.target!.chatModel;
if (!chatModel.isShowChatPage) {
chatModel.toggleCMChatPage(client.id);
}
chatModel.showChatPage(client.id);
}
},
page: desktop.buildConnectionCard(client)));