fix: conv reads when last message is null.

oneRain 2021-06-15 12:30:30 +08:00
parent fbf7d07f85
commit 71d1bff27d
2 changed files with 7 additions and 4 deletions

View File

@ -186,10 +186,13 @@ namespace LeanCloud.Realtime.Internal.Controller {
LCIMMessage msg) {
ReadCommand read = new ReadCommand();
ReadTuple tuple = new ReadTuple {
Cid = convId,
Mid = msg.Id,
Timestamp = msg.SentTimestamp
Cid = convId
};
// 当不传 msg 时,服务端将其收到的最后一条消息标记为已读,可能与客户端不一致
if (msg != null) {
tuple.Mid = msg.Id;
tuple.Timestamp = msg.SentTimestamp;
}
read.Convs.Add(tuple);
GenericCommand command = NewCommand(CommandType.Read);
command.ReadMessage = read;

View File

@ -185,7 +185,7 @@ namespace LeanCloud.Realtime {
/// </summary>
/// <returns></returns>
public virtual async Task Read() {
if (LastMessage == null) {
if (Unread == 0) {
return;
}
await Client.MessageController.Read(Id, LastMessage);