From a7ccccb36871a5c2a767be45336db0294f328a97 Mon Sep 17 00:00:00 2001 From: oneRain Date: Sun, 26 Apr 2020 17:23:36 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=9C=A8=E6=9F=A5=E8=AF=A2=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E6=97=B6=E6=9B=B4=E6=96=B0=E6=9C=80=E5=90=8E=E4=B8=80?= =?UTF-8?q?=E6=9D=A1=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Realtime/Internal/Controller/LCIMMessageController.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Realtime/Internal/Controller/LCIMMessageController.cs b/Realtime/Internal/Controller/LCIMMessageController.cs index 8378080..dbfd49b 100644 --- a/Realtime/Internal/Controller/LCIMMessageController.cs +++ b/Realtime/Internal/Controller/LCIMMessageController.cs @@ -158,7 +158,7 @@ namespace LeanCloud.Realtime.Internal.Controller { request.LogsMessage = logs; GenericCommand response = await Client.Connection.SendRequest(request); // 反序列化聊天记录 - return response.LogsMessage.Logs.Select(item => { + ReadOnlyCollection messages = response.LogsMessage.Logs.Select(item => { LCIMMessage message; if (item.Bin) { // 二进制消息 @@ -179,6 +179,14 @@ namespace LeanCloud.Realtime.Internal.Controller { message.MentionIdList = item.MentionPids.ToList(); return message; }).ToList().AsReadOnly(); + // 查询之后更新对话中的最后一条消息 + LCIMMessage lastMessage = messages.Last(); + LCIMConversation conversation = await Client.GetOrQueryConversation(convId); + if (conversation.LastMessage == null || + conversation.LastMessage.SentTimestamp < lastMessage.SentTimestamp) { + conversation.LastMessage = lastMessage; + } + return messages; } ///