[backend/masto-client] Use Task.WhenAll in timeline controller methods

This commit is contained in:
Laura Hausmann 2024-02-02 20:24:59 +01:00
parent a3fd46bb96
commit 519b5280ac
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -33,7 +33,8 @@ public class MastodonTimelineController(DatabaseContext db, NoteRenderer noteRen
.Take(40) .Take(40)
.ToListAsync(); .ToListAsync();
return Ok(notes.Select(async p => await noteRenderer.RenderAsync(p))); var res = await Task.WhenAll(notes.Select(async p => await noteRenderer.RenderAsync(p)));
return Ok(res);
} }
[AuthorizeOauth("read:statuses")] [AuthorizeOauth("read:statuses")]
@ -48,6 +49,7 @@ public class MastodonTimelineController(DatabaseContext db, NoteRenderer noteRen
.Take(40) .Take(40)
.ToListAsync(); .ToListAsync();
return Ok(notes.Select(async p => await noteRenderer.RenderAsync(p))); var res = await Task.WhenAll(notes.Select(async p => await noteRenderer.RenderAsync(p)));
return Ok(res);
} }
} }