mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 02:57:22 +00:00
@@ -34,6 +34,7 @@ class ChatModel with ChangeNotifier {
|
||||
OverlayEntry? chatWindowOverlayEntry;
|
||||
bool _showOnWindowRestore = false;
|
||||
bool _isWindowMinimized = false;
|
||||
bool isConnManager = false;
|
||||
|
||||
final ChatUser me = ChatUser(
|
||||
id: "",
|
||||
@@ -44,13 +45,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;
|
||||
|
||||
@@ -71,7 +72,6 @@ class ChatModel with ChangeNotifier {
|
||||
setWindowMinimized(bool v) {
|
||||
_isWindowMinimized = v;
|
||||
if (!_isWindowMinimized && _showOnWindowRestore) {
|
||||
showChatIconOverlay();
|
||||
_showOnWindowRestore = false;
|
||||
}
|
||||
}
|
||||
@@ -158,9 +158,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();
|
||||
@@ -172,12 +174,24 @@ 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);
|
||||
@@ -185,7 +199,7 @@ class ChatModel with ChangeNotifier {
|
||||
await windowManager.setSize(Size(600, 400));
|
||||
await Future.delayed(Duration(milliseconds: 100));
|
||||
await windowManager.setAlignment(Alignment.topRight);
|
||||
_isShowChatPage = !_isShowChatPage;
|
||||
_isShowCMChatPage = !_isShowCMChatPage;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -219,17 +233,11 @@ class ChatModel with ChangeNotifier {
|
||||
}
|
||||
if (text.isEmpty) return;
|
||||
// mobile: first message show overlay icon
|
||||
if (chatIconOverlayEntry == null) {
|
||||
if (_isWindowMinimized) {
|
||||
showChatIconOverlay();
|
||||
} else {
|
||||
_showOnWindowRestore = true;
|
||||
}
|
||||
}
|
||||
// desktop: show chat page
|
||||
if (!_isShowChatPage) {
|
||||
toggleCMChatPage(id);
|
||||
if (!isDesktop && chatIconOverlayEntry == null) {
|
||||
showChatIconOverlay();
|
||||
}
|
||||
// show chat page
|
||||
await showChatPage(id);
|
||||
|
||||
int toId = currentID;
|
||||
|
||||
|
||||
@@ -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)));
|
||||
|
||||
Reference in New Issue
Block a user