Skip to content

Commit

Permalink
fix: merge props after creating conv
Browse files Browse the repository at this point in the history
  • Loading branch information
leancloud-bot committed Jun 20, 2023
1 parent c3e91ea commit e8d6f66
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Realtime/Realtime.Test/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using LeanCloud;
using LeanCloud.Realtime;
using LeanCloud.Storage;
Expand Down Expand Up @@ -63,16 +64,23 @@ public async Task CreateConversation() {
WriteLine(conv.CreatorId);
};

string name = Guid.NewGuid().ToString();

client.OnMembersJoined = (conv, memberList, initBy) => {
WriteLine($"custom id: {conv["custom_id"]}");
Assert.AreEqual(conv["custom_id"], name);
WriteLine($"on members joined: {initBy}");
foreach (string memberId in conv.MemberIds) {
WriteLine(memberId);
}
tcs.SetResult(null);
};

string name = Guid.NewGuid().ToString();
LCIMConversation conversation = await client.CreateConversation(new string[] { "world" }, name: name, unique: false);
Dictionary<string, object> props = new Dictionary<string, object> {
{ "custom_id", name }
};
LCIMConversation conversation = await client.CreateConversation(new string[] { "world" },
name: name, unique: false, properties: props);

await tcs.Task;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ internal async Task<LCIMConversation> CreateConv(
} else {
conversation = new LCIMConversation(Client);
}
conversation.MergeFrom(properties);
Client.ConversationDict[convId] = conversation;
}
// 合并请求数据
Expand Down
4 changes: 4 additions & 0 deletions Realtime/Realtime/Public/Conversation/LCIMConversation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,10 @@ internal static bool IsTemporayConversation(string convId) {
}

internal void MergeFrom(Dictionary<string, object> conv) {
if (conv == null) {
return;
}

foreach (KeyValuePair<string, object> kv in conv) {
if (kv.Key == "objectId") {
Id = kv.Value as string;
Expand Down

0 comments on commit e8d6f66

Please sign in to comment.