diff --git a/Realtime/Realtime/Conversation/LCIMChatRoom.cs b/Realtime/Realtime/Conversation/LCIMChatRoom.cs index 5b77f92..0ecccf1 100644 --- a/Realtime/Realtime/Conversation/LCIMChatRoom.cs +++ b/Realtime/Realtime/Conversation/LCIMChatRoom.cs @@ -32,5 +32,9 @@ namespace LeanCloud.Realtime { public override Task Read() { return Task.CompletedTask; } + + public override Task FetchReciptTimestamps() { + return Task.CompletedTask; + } } } diff --git a/Realtime/Realtime/Conversation/LCIMConversation.cs b/Realtime/Realtime/Conversation/LCIMConversation.cs index c2553d5..f74ace8 100644 --- a/Realtime/Realtime/Conversation/LCIMConversation.cs +++ b/Realtime/Realtime/Conversation/LCIMConversation.cs @@ -467,7 +467,7 @@ namespace LeanCloud.Realtime { /// Fetches receipt timestamp. /// /// - public async Task FetchReciptTimestamps() { + public virtual async Task FetchReciptTimestamps() { await Client.ConversationController.FetchReciptTimestamp(Id); } diff --git a/Realtime/Realtime/Conversation/LCIMServiceConversation.cs b/Realtime/Realtime/Conversation/LCIMServiceConversation.cs index b2159a6..d55a16f 100644 --- a/Realtime/Realtime/Conversation/LCIMServiceConversation.cs +++ b/Realtime/Realtime/Conversation/LCIMServiceConversation.cs @@ -17,5 +17,9 @@ namespace LeanCloud.Realtime { public async Task CheckSubscription() { return await Client.ConversationController.CheckSubscription(Id); } + + public override Task FetchReciptTimestamps() { + return Task.CompletedTask; + } } } diff --git a/Realtime/Realtime/Message/LCIMMessage.cs b/Realtime/Realtime/Message/LCIMMessage.cs index 4652845..85bdf01 100644 --- a/Realtime/Realtime/Message/LCIMMessage.cs +++ b/Realtime/Realtime/Message/LCIMMessage.cs @@ -120,8 +120,8 @@ namespace LeanCloud.Realtime { /// /// Indicates whether this message is transient. /// - public bool IsTransient { - get; internal set; + internal bool IsTransient { + get; set; } internal LCIMMessage() { diff --git a/Storage/Storage/LCQuery.cs b/Storage/Storage/LCQuery.cs index 928bc1e..c9396f7 100644 --- a/Storage/Storage/LCQuery.cs +++ b/Storage/Storage/LCQuery.cs @@ -346,12 +346,13 @@ namespace LeanCloud.Storage { return (int)ret["count"]; } - public Task Get(string objectId) { + public async Task Get(string objectId) { if (string.IsNullOrEmpty(objectId)) { throw new ArgumentNullException(nameof(objectId)); } - WhereEqualTo("objectId", objectId); - return First(); + string path = $"classes/{ClassName}/{objectId}"; + Dictionary response = await LCApplication.HttpClient.Get>(path); + return DecodeLCObject(response); } public async Task> Find() { @@ -361,9 +362,7 @@ namespace LeanCloud.Storage { List results = response["results"] as List; List list = new List(); foreach (object item in results) { - LCObjectData objectData = LCObjectData.Decode(item as Dictionary); - T obj = LCObject.Create(ClassName) as T; - obj.Merge(objectData); + T obj = DecodeLCObject(item as Dictionary); list.Add(obj); } return list.AsReadOnly(); @@ -412,5 +411,12 @@ namespace LeanCloud.Storage { compositionQuery.ClassName = className; return compositionQuery; } + + private T DecodeLCObject(Dictionary data) { + LCObjectData objectData = LCObjectData.Decode(data); + T obj = LCObject.Create(ClassName) as T; + obj.Merge(objectData); + return obj; + } } } diff --git a/Storage/Storage/LCUser.cs b/Storage/Storage/LCUser.cs index af1aa03..70e8f28 100644 --- a/Storage/Storage/LCUser.cs +++ b/Storage/Storage/LCUser.cs @@ -326,7 +326,7 @@ namespace LeanCloud.Storage { if (string.IsNullOrEmpty(platform)) { throw new ArgumentNullException(nameof(platform)); } - return LinkWithAuthData(platform, null); + return UnlinkWithAuthData(platform); } /// @@ -523,11 +523,34 @@ namespace LeanCloud.Storage { return new LCQuery(CLASS_NAME); } - Task LinkWithAuthData(string authType, Dictionary data) { + async Task LinkWithAuthData(string authType, Dictionary data) { + Dictionary oriAuthData = new Dictionary(AuthData); AuthData = new Dictionary { { authType, data } }; - return Save(); + try { + await Save(); + oriAuthData.Add(authType, data); + AuthData = oriAuthData; + } catch (Exception e) { + AuthData = oriAuthData; + throw e; + } + } + + async Task UnlinkWithAuthData(string authType) { + Dictionary oriAuthData = new Dictionary(AuthData); + AuthData = new Dictionary { + { authType, null } + }; + try { + await Save(); + oriAuthData.Remove(authType); + AuthData = oriAuthData; + } catch (Exception e) { + AuthData = oriAuthData; + throw e; + } } static async Task Login(Dictionary data) { diff --git a/Storage/Storage/Leaderboard/LCLeaderboard.cs b/Storage/Storage/Leaderboard/LCLeaderboard.cs index 8062563..29b39b7 100644 --- a/Storage/Storage/Leaderboard/LCLeaderboard.cs +++ b/Storage/Storage/Leaderboard/LCLeaderboard.cs @@ -97,7 +97,7 @@ namespace LeanCloud.Storage { public static async Task> UpdateStatistics(LCUser user, Dictionary statistics, - bool overwrite = true) { + bool overwrite = false) { if (user == null) { throw new ArgumentNullException(nameof(user)); }