feat: support OnLastDeliveredAt, OnLastReadAt
parent
9a555a386c
commit
778cb622b6
|
@ -2,6 +2,9 @@
|
|||
using System.Collections;
|
||||
using System.Collections.ObjectModel;
|
||||
using LeanCloud.Storage.Internal.Query;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace LeanCloud.Realtime {
|
||||
public class LCIMConversationQuery {
|
||||
|
@ -274,5 +277,15 @@ namespace LeanCloud.Realtime {
|
|||
public async Task<ReadOnlyCollection<LCIMConversation>> Find() {
|
||||
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);
|
||||
if (isRead) {
|
||||
Client.OnMessageRead?.Invoke(conversation, msgId);
|
||||
if (timestamp > conversation.LastReadTimestamp) {
|
||||
conversation.LastReadTimestamp = timestamp;
|
||||
Client.OnLastReadAtUpdated?.Invoke(conversation);
|
||||
}
|
||||
} else {
|
||||
Client.OnMessageDelivered?.Invoke(conversation, msgId);
|
||||
if (timestamp > conversation.LastDeliveredTimestamp) {
|
||||
conversation.LastDeliveredTimestamp = timestamp;
|
||||
Client.OnLastDeliveredAtUpdated?.Invoke(conversation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -204,14 +204,14 @@ namespace LeanCloud.Realtime {
|
|||
/// <summary>
|
||||
/// Occurs when the last delivered message is updated.
|
||||
/// </summary>
|
||||
public Action OnLastDeliveredAtUpdated {
|
||||
public Action<LCIMConversation> OnLastDeliveredAtUpdated {
|
||||
get; set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the last delivered message is updated.
|
||||
/// Occurs when the last read message is updated.
|
||||
/// </summary>
|
||||
public Action OnLastReadAtUpdated {
|
||||
public Action<LCIMConversation> OnLastReadAtUpdated {
|
||||
get; set;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue