Merge pull request #4917 from 21pages/fix_chat

Fix chat
This commit is contained in:
RustDesk 2023-07-08 16:40:31 +08:00 committed by GitHub
commit 91c53b1db4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 13 deletions

View File

@ -104,6 +104,12 @@ class ConnectionManagerState extends State<ConnectionManager> {
final client = final client =
gFFI.serverModel.clients.firstWhereOrNull((e) => e.id == client_id); gFFI.serverModel.clients.firstWhereOrNull((e) => e.id == client_id);
if (client != null) { if (client != null) {
if (client.unreadChatMessageCount.value > 0) {
Future.delayed(Duration.zero, () {
client.unreadChatMessageCount.value = 0;
gFFI.chatModel.showChatPage(client.id);
});
}
windowManager.setTitle(getWindowNameWithId(client.peerId)); windowManager.setTitle(getWindowNameWithId(client.peerId));
} }
} }
@ -168,7 +174,13 @@ class ConnectionManagerState extends State<ConnectionManager> {
builder: (_, model, child) => model.isShowCMChatPage builder: (_, model, child) => model.isShowCMChatPage
? Expanded( ? Expanded(
child: buildRemoteBlock( child: buildRemoteBlock(
child: ChatPage(), child: Container(
decoration: BoxDecoration(
border: Border(
right: BorderSide(
color: Theme.of(context)
.dividerColor))),
child: ChatPage()),
), ),
flex: (kConnectionManagerWindowSizeOpenChat.width - flex: (kConnectionManagerWindowSizeOpenChat.width -
kConnectionManagerWindowSizeClosedChat kConnectionManagerWindowSizeClosedChat

View File

@ -234,13 +234,21 @@ class ChatModel with ChangeNotifier {
} }
showChatPage(int id) async { showChatPage(int id) async {
if (isConnManager) { if (isDesktop) {
if (!_isShowCMChatPage) { if (isConnManager) {
await toggleCMChatPage(id); if (!_isShowCMChatPage) {
await toggleCMChatPage(id);
}
} else {
if (_isChatOverlayHide()) {
await toggleChatOverlay();
}
} }
} else { } else {
if (_isChatOverlayHide()) { if (id == clientModeID) {
await toggleChatOverlay(); if (_isChatOverlayHide()) {
await toggleChatOverlay();
}
} }
} }
} }

View File

@ -462,13 +462,7 @@ class ServerModel with ChangeNotifier {
key: client.id.toString(), key: client.id.toString(),
label: client.name, label: client.name,
closable: false, closable: false,
onTap: () { onTap: () {},
if (client.unreadChatMessageCount.value > 0) {
client.unreadChatMessageCount.value = 0;
final chatModel = parent.target!.chatModel;
chatModel.showChatPage(client.id);
}
},
page: desktop.buildConnectionCard(client))); page: desktop.buildConnectionCard(client)));
Future.delayed(Duration.zero, () async { Future.delayed(Duration.zero, () async {
if (!hideCm) window_on_top(null); if (!hideCm) window_on_top(null);