Merge pull request #128 from onerain88/fix-user-save
Fix user save
commit
f833cd6953
|
@ -19,7 +19,7 @@ namespace LeanCloud.Common {
|
|||
}
|
||||
|
||||
string path = GetFileFullPath(filename);
|
||||
using (FileStream fs = IOFile.OpenWrite(path)) {
|
||||
using (FileStream fs = IOFile.Create(path)) {
|
||||
byte[] buffer = Encoding.UTF8.GetBytes(text);
|
||||
await fs.WriteAsync(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
|
|
@ -572,8 +572,8 @@ namespace LeanCloud.Storage {
|
|||
public void Merge(LCObjectData objectData) {
|
||||
data.ClassName = objectData.ClassName ?? data.ClassName;
|
||||
data.ObjectId = objectData.ObjectId ?? data.ObjectId;
|
||||
data.CreatedAt = objectData.CreatedAt != null ? objectData.CreatedAt : data.CreatedAt;
|
||||
data.UpdatedAt = objectData.UpdatedAt != null ? objectData.UpdatedAt : data.UpdatedAt;
|
||||
data.CreatedAt = !objectData.CreatedAt.Equals(default) ? objectData.CreatedAt : data.CreatedAt;
|
||||
data.UpdatedAt = !objectData.UpdatedAt.Equals(default) ? objectData.UpdatedAt : data.UpdatedAt;
|
||||
// 先将本地的预估数据直接替换
|
||||
data.CustomPropertyDict = estimatedData;
|
||||
// 再将服务端的数据覆盖
|
||||
|
|
|
@ -127,9 +127,6 @@ namespace LeanCloud.Storage {
|
|||
throw new ArgumentException("Cannot sign up a user that already exists.");
|
||||
}
|
||||
await Save();
|
||||
currentUser = this;
|
||||
|
||||
await SaveToLocal();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -555,7 +552,7 @@ namespace LeanCloud.Storage {
|
|||
{ authType, data }
|
||||
};
|
||||
try {
|
||||
await Save();
|
||||
await base.Save();
|
||||
oriAuthData[authType] = data;
|
||||
await UpdateAuthData(oriAuthData);
|
||||
} catch (Exception e) {
|
||||
|
@ -570,7 +567,7 @@ namespace LeanCloud.Storage {
|
|||
{ authType, null }
|
||||
};
|
||||
try {
|
||||
await Save();
|
||||
await base.Save();
|
||||
oriAuthData.Remove(authType);
|
||||
await UpdateAuthData(oriAuthData);
|
||||
} catch (Exception e) {
|
||||
|
@ -765,5 +762,12 @@ namespace LeanCloud.Storage {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public new async Task<LCUser> Save(bool fetchWhenSave = false, LCQuery<LCObject> query = null) {
|
||||
await base.Save(fetchWhenSave, query);
|
||||
currentUser = this;
|
||||
await SaveToLocal();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue