diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-05-04 15:26:17 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-05-04 15:26:17 +0200 |
commit | dc3201d641a03e051c6f0db07612eb6b0bb506c3 (patch) | |
tree | f4a57bcfbdf0be6a373df342d26b76bdbf43e2e9 /MatrixRoomUtils.Core/Room.cs | |
parent | Fix bugs in policy editor and state viewer (diff) | |
download | MatrixUtils-dc3201d641a03e051c6f0db07612eb6b0bb506c3.tar.xz |
Dark theme, fancier room list
Diffstat (limited to 'MatrixRoomUtils.Core/Room.cs')
-rw-r--r-- | MatrixRoomUtils.Core/Room.cs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/MatrixRoomUtils.Core/Room.cs b/MatrixRoomUtils.Core/Room.cs index fff5013..d5eee2b 100644 --- a/MatrixRoomUtils.Core/Room.cs +++ b/MatrixRoomUtils.Core/Room.cs @@ -14,9 +14,8 @@ public class Room RoomId = roomId; } - public async Task<JsonElement?> GetStateAsync(string type, string state_key="") + public async Task<JsonElement?> GetStateAsync(string type, string state_key="", bool logOnFailure = false) { - Console.WriteLine($"{RoomId}::_qry[{type}::{state_key}]"); var url = $"/_matrix/client/r0/rooms/{RoomId}/state"; if (!string.IsNullOrEmpty(state_key)) url += $"/{type}/{state_key}"; else if (!string.IsNullOrEmpty(type)) url += $"/{type}"; @@ -24,21 +23,18 @@ public class Room var res = await _httpClient.GetAsync(url); if (!res.IsSuccessStatusCode) { - Console.WriteLine($"{RoomId}::_qry[{type}::{state_key}]->status=={res.StatusCode}"); + if(logOnFailure) Console.WriteLine($"{RoomId}/{state_key}/{type} - got status: {res.StatusCode}"); return null; } return await res.Content.ReadFromJsonAsync<JsonElement>(); } public async Task<string?> GetNameAsync() - { - Console.WriteLine($"{RoomId}::_qry_name"); + { var res = await GetStateAsync("m.room.name"); if (!res.HasValue) { - Console.WriteLine($"{RoomId}::_qry_name->null"); return null; } - Console.WriteLine($"{RoomId}::_qry_name->{res.Value.ToString()}"); var resn = res?.TryGetProperty("name", out var name) ?? false ? name.GetString() : null; Console.WriteLine($"Got name: {resn}"); return resn; |