about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Pages/DebugTools.razor
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Web/Pages/DebugTools.razor')
-rw-r--r--MatrixRoomUtils.Web/Pages/DebugTools.razor48
1 files changed, 20 insertions, 28 deletions
diff --git a/MatrixRoomUtils.Web/Pages/DebugTools.razor b/MatrixRoomUtils.Web/Pages/DebugTools.razor

index c8fabaa..da5c172 100644 --- a/MatrixRoomUtils.Web/Pages/DebugTools.razor +++ b/MatrixRoomUtils.Web/Pages/DebugTools.razor
@@ -1,26 +1,24 @@ @page "/Debug" -@using MatrixRoomUtils.Core.Interfaces -@using MatrixRoomUtils.Core.Extensions @using System.Reflection +@using MatrixRoomUtils.Core.Extensions +@using MatrixRoomUtils.Core.Interfaces @inject ILocalStorageService LocalStorage @inject NavigationManager NavigationManager <h3>Debug Tools</h3> <hr/> -@if (Rooms.Count == 0) -{ +@if (Rooms.Count == 0) { <p>You are not in any rooms!</p> @* <p>Loading progress: @checkedRoomCount/@totalRoomCount</p> *@ } -else -{ +else { <details> <summary>Room List</summary> - @foreach (var room in Rooms) - { - <a style="color: unset; text-decoration: unset;" href="/RoomStateViewer/@room.Replace('.', '~')"><RoomListItem RoomId="@room"></RoomListItem></a> + @foreach (var room in Rooms) { + <a style="color: unset; text-decoration: unset;" href="/RoomStateViewer/@room.Replace('.', '~')"> + <RoomListItem RoomId="@room"></RoomListItem> + </a> } </details> - } <details open> @@ -38,50 +36,44 @@ else @code { public List<string> Rooms { get; set; } = new(); - protected override async Task OnInitializedAsync() - { + + protected override async Task OnInitializedAsync() { await LocalStorageWrapper.LoadFromLocalStorage(LocalStorage); await base.OnInitializedAsync(); - if (RuntimeCache.CurrentHomeServer == null) - { + if (RuntimeCache.CurrentHomeServer == null) { NavigationManager.NavigateTo("/Login"); return; } - Rooms = (await RuntimeCache.CurrentHomeServer.GetJoinedRooms()).Select(x=>x.RoomId).ToList(); + Rooms = (await RuntimeCache.CurrentHomeServer.GetJoinedRooms()).Select(x => x.RoomId).ToList(); Console.WriteLine("Fetched joined rooms!"); } - //send req string get_request_url { get; set; } = ""; string get_request_result { get; set; } = ""; - private async Task SendGetRequest() - { + + private async Task SendGetRequest() { var field = typeof(IHomeServer).GetRuntimeFields().First(x => x.ToString().Contains("<_httpClient>k__BackingField")); var httpClient = field.GetValue(RuntimeCache.CurrentHomeServer) as HttpClient; - try - { + try { var res = await httpClient.GetAsync(get_request_url); - if (res.IsSuccessStatusCode) - { - if(res.Content.Headers.ContentType.MediaType == "application/json") + if (res.IsSuccessStatusCode) { + if (res.Content.Headers.ContentType.MediaType == "application/json") get_request_result = (await res.Content.ReadFromJsonAsync<object>()).ToJson(); else get_request_result = await res.Content.ReadAsStringAsync(); StateHasChanged(); return; } - if(res.Content.Headers.ContentType.MediaType == "application/json") + if (res.Content.Headers.ContentType.MediaType == "application/json") get_request_result = $"Error: {res.StatusCode}\n" + (await res.Content.ReadFromJsonAsync<object>()).ToJson(); else get_request_result = $"Error: {res.StatusCode}\n" + await res.Content.ReadAsStringAsync(); - } - catch (Exception e) - { + catch (Exception e) { get_request_result = $"Error: {e}"; } StateHasChanged(); } -} \ No newline at end of file +} \ No newline at end of file