Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Mar 28, 2024
1 parent 3fcb4ca commit 0242d3d
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Snap.Hutao.Service.User;
[Injection(InjectAs.Singleton, typeof(IUserCollectionService))]
internal sealed partial class UserCollectionService : IUserCollectionService, IDisposable
{
private readonly ScopedDbCurrent<BindingUser, Model.Entity.User, UserChangedMessage> dbCurrent;
private readonly ScopedDbCurrent<BindingUser, EntityUser, UserChangedMessage> dbCurrent;
private readonly IUserInitializationService userInitializationService;
private readonly IServiceProvider serviceProvider;
private readonly IUserDbService userDbService;
Expand Down Expand Up @@ -163,7 +163,7 @@ public async ValueTask<ValueResult<UserOptionResult, string>> TryCreateAndAddUse

// Sync cache
await taskContext.SwitchToMainThreadAsync();
userCollection.Add(newUser);
userCollection.Add(newUser); // Database synced in the collection
if (newUser.Entity.Mid is not null)
{
midUserMap?.Add(newUser.Entity.Mid, newUser);
Expand All @@ -178,9 +178,6 @@ public async ValueTask<ValueResult<UserOptionResult, string>> TryCreateAndAddUse
}
}

// Sync database
await taskContext.SwitchToBackgroundAsync();
await userDbService.AddUserAsync(newUser.Entity).ConfigureAwait(false);
ArgumentNullException.ThrowIfNull(newUser.UserInfo);
return new(UserOptionResult.Added, newUser.UserInfo.Uid);
}
Expand Down

0 comments on commit 0242d3d

Please sign in to comment.