feat: support OnLastDeliveredAt, OnLastReadAt
parent
9a555a386c
commit
778cb622b6
|
@ -2,6 +2,9 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using LeanCloud.Storage.Internal.Query;
|
using LeanCloud.Storage.Internal.Query;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace LeanCloud.Realtime {
|
namespace LeanCloud.Realtime {
|
||||||
public class LCIMConversationQuery {
|
public class LCIMConversationQuery {
|
||||||
|
@ -274,5 +277,15 @@ namespace LeanCloud.Realtime {
|
||||||
public async Task<ReadOnlyCollection<LCIMConversation>> Find() {
|
public async Task<ReadOnlyCollection<LCIMConversation>> Find() {
|
||||||
return await client.ConversationController.Find(this);
|
return await client.ConversationController.Find(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the first conversation from the query.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<LCIMConversation> First() {
|
||||||
|
Limit(1);
|
||||||
|
ReadOnlyCollection<LCIMConversation> conversations = await Find();
|
||||||
|
return conversations?.First();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,8 +285,16 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
||||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convId);
|
LCIMConversation conversation = await Client.GetOrQueryConversation(convId);
|
||||||
if (isRead) {
|
if (isRead) {
|
||||||
Client.OnMessageRead?.Invoke(conversation, msgId);
|
Client.OnMessageRead?.Invoke(conversation, msgId);
|
||||||
|
if (timestamp > conversation.LastReadTimestamp) {
|
||||||
|
conversation.LastReadTimestamp = timestamp;
|
||||||
|
Client.OnLastReadAtUpdated?.Invoke(conversation);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Client.OnMessageDelivered?.Invoke(conversation, msgId);
|
Client.OnMessageDelivered?.Invoke(conversation, msgId);
|
||||||
|
if (timestamp > conversation.LastDeliveredTimestamp) {
|
||||||
|
conversation.LastDeliveredTimestamp = timestamp;
|
||||||
|
Client.OnLastDeliveredAtUpdated?.Invoke(conversation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,14 +204,14 @@ namespace LeanCloud.Realtime {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when the last delivered message is updated.
|
/// Occurs when the last delivered message is updated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action OnLastDeliveredAtUpdated {
|
public Action<LCIMConversation> OnLastDeliveredAtUpdated {
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when the last delivered message is updated.
|
/// Occurs when the last read message is updated.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action OnLastReadAtUpdated {
|
public Action<LCIMConversation> OnLastReadAtUpdated {
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue