[backend/database] Fix DatabaseContext.ReloadEntityRecursivelyAsync

This commit is contained in:
Laura Hausmann 2024-03-01 19:45:22 +01:00
parent 4c3a140e9f
commit ab5258237d
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 4 additions and 4 deletions

View file

@ -1144,13 +1144,13 @@ public class DatabaseContext(DbContextOptions<DatabaseContext> options)
await Entry(entity).ReloadAsync(); await Entry(entity).ReloadAsync();
} }
public async Task ReloadEntityRecursiveAsync(object entity) public async Task ReloadEntityRecursivelyAsync(object entity)
{ {
await ReloadEntityAsync(entity); await ReloadEntityAsync(entity);
await Entry(entity) await Entry(entity)
.References.Where(p => p is { IsLoaded: true, TargetEntry: not null }) .References.Where(p => p is { IsLoaded: true, TargetEntry: not null })
.Select(p => p.TargetEntry!.ReloadAsync()) .Select(p => p.TargetEntry!.ReloadAsync())
.AwaitAllAsync(); .AwaitAllNoConcurrencyAsync();
} }
public IQueryable<Note> NoteAncestors(string noteId, int depth) public IQueryable<Note> NoteAncestors(string noteId, int depth)

View file

@ -237,7 +237,7 @@ public class UserResolver(
} }
if (success) if (success)
await db.ReloadEntityRecursiveAsync(user); await db.ReloadEntityRecursivelyAsync(user);
return user; return user;
} }

View file

@ -782,7 +782,7 @@ public class UserService(
await task.SafeWaitAsync(TimeSpan.FromMilliseconds(500)); await task.SafeWaitAsync(TimeSpan.FromMilliseconds(500));
if (success) if (success)
await db.ReloadEntityRecursiveAsync(user); await db.ReloadEntityRecursivelyAsync(user);
return user; return user;
} }