[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

@ -32,8 +32,9 @@ public class MastodonTimelineController(DatabaseContext db, NoteRenderer noteRen
.OrderByIdDesc()
.Take(40)
.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")]
@ -47,7 +48,8 @@ public class MastodonTimelineController(DatabaseContext db, NoteRenderer noteRen
.OrderByIdDesc()
.Take(40)
.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);
}
}