@page "/Debug" @using System.Reflection @using LibMatrix.Extensions @using LibMatrix.Interfaces @inject ILocalStorageService LocalStorage @inject NavigationManager NavigationManager

Debug Tools


@if (Rooms.Count == 0) {

You are not in any rooms!

@*

Loading progress: @checkedRoomCount/@totalRoomCount

*@ } else {
Room List @foreach (var room in Rooms) { }
}
Send GET request to URL

@get_request_result
@code { public List Rooms { get; set; } = new(); protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); var hs = await MRUStorage.GetCurrentSessionOrNavigate(); if (hs == null) return; Rooms = (await hs.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() { var field = typeof(IHomeServer).GetRuntimeFields().First(x => x.ToString().Contains("<_httpClient>k__BackingField")); var hs = await MRUStorage.GetCurrentSessionOrNavigate(); if (hs == null) return; var httpClient = field.GetValue(hs) as MatrixHttpClient; try { var res = await httpClient.GetAsync(get_request_url); if (res.IsSuccessStatusCode) { if (res.Content.Headers.ContentType.MediaType == "application/json") get_request_result = (await res.Content.ReadFromJsonAsync()).ToJson(); else get_request_result = await res.Content.ReadAsStringAsync(); StateHasChanged(); return; } if (res.Content.Headers.ContentType.MediaType == "application/json") get_request_result = $"Error: {res.StatusCode}\n" + (await res.Content.ReadFromJsonAsync()).ToJson(); else get_request_result = $"Error: {res.StatusCode}\n" + await res.Content.ReadAsStringAsync(); } catch (Exception e) { get_request_result = $"Error: {e}"; } StateHasChanged(); } }