diff --git a/Realtime/Conversation/LCIMConversation.cs b/Realtime/Conversation/LCIMConversation.cs index b9556ce..2e40ddc 100644 --- a/Realtime/Conversation/LCIMConversation.cs +++ b/Realtime/Conversation/LCIMConversation.cs @@ -164,6 +164,9 @@ namespace LeanCloud.Realtime { internal LCIMConversation(LCIMClient client) { Client = client; customProperties = new Dictionary(); + ids = new HashSet(); + mutedIds = new HashSet(); + customProperties = new Dictionary(); } /// @@ -210,7 +213,9 @@ namespace LeanCloud.Realtime { if (clientIds == null || clientIds.Count() == 0) { throw new ArgumentNullException(nameof(clientIds)); } - return await Client.ConversationController.AddMembers(Id, clientIds); + LCIMPartiallySuccessResult result = await Client.ConversationController.AddMembers(Id, clientIds); + ids.UnionWith(result.SuccessfulClientIdList); + return result; } /// @@ -222,7 +227,9 @@ namespace LeanCloud.Realtime { if (removeIds == null || removeIds.Count() == 0) { throw new ArgumentNullException(nameof(removeIds)); } - return await Client.ConversationController.RemoveMembers(Id, removeIds); + LCIMPartiallySuccessResult result = await Client.ConversationController.RemoveMembers(Id, removeIds); + ids.RemoveWhere(id => result.SuccessfulClientIdList.Contains(id)); + return result; } /// @@ -294,7 +301,11 @@ namespace LeanCloud.Realtime { if (clientIds == null || clientIds.Count() == 0) { throw new ArgumentNullException(nameof(clientIds)); } - return await Client.ConversationController.MuteMembers(Id, clientIds); + LCIMPartiallySuccessResult result = await Client.ConversationController.MuteMembers(Id, clientIds); + if (result.SuccessfulClientIdList != null) { + mutedIds.UnionWith(result.SuccessfulClientIdList); + } + return result; } /// @@ -306,7 +317,11 @@ namespace LeanCloud.Realtime { if (clientIds == null || clientIds.Count() == 0) { throw new ArgumentNullException(nameof(clientIds)); } - return await Client.ConversationController.UnmuteMembers(Id, clientIds); + LCIMPartiallySuccessResult result = await Client.ConversationController.UnmuteMembers(Id, clientIds); + if (result.SuccessfulClientIdList != null) { + mutedIds.RemoveWhere(id => result.SuccessfulClientIdList.Contains(id)); + } + return result; } /// diff --git a/Realtime/Internal/Controller/LCIMConversationController.cs b/Realtime/Internal/Controller/LCIMConversationController.cs index 019d291..4029254 100644 --- a/Realtime/Internal/Controller/LCIMConversationController.cs +++ b/Realtime/Internal/Controller/LCIMConversationController.cs @@ -375,9 +375,11 @@ namespace LeanCloud.Realtime.Internal.Controller { string next = null) { ConvCommand conv = new ConvCommand { Cid = convId, - Limit = limit, - Next = next + Limit = limit }; + if (next != null) { + conv.Next = next; + } GenericCommand request = NewCommand(CommandType.Conv, OpType.QueryShutup); request.ConvMessage = conv; GenericCommand response = await Client.Connection.SendRequest(request); @@ -399,9 +401,11 @@ namespace LeanCloud.Realtime.Internal.Controller { string next = null) { BlacklistCommand black = new BlacklistCommand { SrcCid = convId, - Limit = limit, - Next = next + Limit = limit }; + if (next != null) { + black.Next = next; + } GenericCommand request = NewCommand(CommandType.Blacklist, OpType.Query); request.BlacklistMessage = black; GenericCommand response = await Client.Connection.SendRequest(request); @@ -620,7 +624,7 @@ namespace LeanCloud.Realtime.Internal.Controller { private async Task OnMembersJoined(ConvCommand convMessage) { LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); ReadOnlyCollection joinedIds = new ReadOnlyCollection(convMessage.M); - conversation.ids.Union(joinedIds); + conversation.ids.UnionWith(joinedIds); Client.OnMembersJoined?.Invoke(conversation, joinedIds, convMessage.InitBy); } @@ -666,7 +670,7 @@ namespace LeanCloud.Realtime.Internal.Controller { private async Task OnMembersMuted(ConvCommand convMessage) { LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); ReadOnlyCollection mutedMemberIds = new ReadOnlyCollection(convMessage.M); - conversation.mutedIds.Union(mutedMemberIds); + conversation.mutedIds.UnionWith(mutedMemberIds); Client.OnMembersMuted?.Invoke(conversation, mutedMemberIds, convMessage.InitBy); }