diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-08-14 19:46:11 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-08-14 19:46:11 +0200 |
commit | cb8846a7a3310f8513989da5aadb5202f048a1b3 (patch) | |
tree | cfbcf2506947d0f820208dd4cdb7a56c660ef0f9 /LibMatrix/AuthenticatedHomeServer.cs | |
parent | Update dependencies (diff) | |
download | LibMatrix-cb8846a7a3310f8513989da5aadb5202f048a1b3.tar.xz |
Code cleanup
Diffstat (limited to 'LibMatrix/AuthenticatedHomeServer.cs')
-rw-r--r-- | LibMatrix/AuthenticatedHomeServer.cs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/LibMatrix/AuthenticatedHomeServer.cs b/LibMatrix/AuthenticatedHomeServer.cs index 102d448..a99dc27 100644 --- a/LibMatrix/AuthenticatedHomeServer.cs +++ b/LibMatrix/AuthenticatedHomeServer.cs @@ -32,14 +32,13 @@ public class AuthenticatedHomeServer : IHomeServer { public string AccessToken { get; set; } - public async Task<GenericRoom> GetRoom(string roomId) => new(this, roomId); + public Task<GenericRoom> GetRoom(string roomId) => Task.FromResult<GenericRoom>(new(this, roomId)); public async Task<List<GenericRoom>> GetJoinedRooms() { - var rooms = new List<GenericRoom>(); var roomQuery = await _httpClient.GetAsync("/_matrix/client/v3/joined_rooms"); var roomsJson = await roomQuery.Content.ReadFromJsonAsync<JsonElement>(); - foreach (var room in roomsJson.GetProperty("joined_rooms").EnumerateArray()) rooms.Add(new GenericRoom(this, room.GetString())); + var rooms = roomsJson.GetProperty("joined_rooms").EnumerateArray().Select(room => new GenericRoom(this, room.GetString()!)).ToList(); Console.WriteLine($"Fetched {rooms.Count} rooms"); |