From 03313562d21d5db9bf6a14ebbeab80e06c883d3a Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 24 Jan 2024 02:31:56 +0100 Subject: MRU->RMU, fixes, cleanup --- MatrixUtils.Web/Pages/Dev/DevUtilities.razor | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 MatrixUtils.Web/Pages/Dev/DevUtilities.razor (limited to 'MatrixUtils.Web/Pages/Dev/DevUtilities.razor') diff --git a/MatrixUtils.Web/Pages/Dev/DevUtilities.razor b/MatrixUtils.Web/Pages/Dev/DevUtilities.razor new file mode 100644 index 0000000..a6a4a82 --- /dev/null +++ b/MatrixUtils.Web/Pages/Dev/DevUtilities.razor @@ -0,0 +1,78 @@ +@page "/Dev/Utilities" +@using System.Reflection +@using ArcaneLibs.Extensions +@using LibMatrix.Extensions +@using LibMatrix.Homeservers +@using MatrixUtils.Abstractions +@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 +
+ + +
+
+
@GetRequestResult
+
+ +
+ + +@code { + public List Rooms { get; set; } = new(); + public AuthenticatedHomeserverGeneric? hs { get; set; } + + protected override async Task OnInitializedAsync() { + await base.OnInitializedAsync(); + hs = await RMUStorage.GetCurrentSessionOrNavigate(); + if (hs == null) return; + Rooms = (await hs.GetJoinedRooms()).Select(x => x.RoomId).ToList(); + Console.WriteLine("Fetched joined rooms!"); + } + + //send req + string GetRequestUrl { get; set; } = ""; + string GetRequestResult { get; set; } = ""; + + private async Task SendGetRequest() { + var httpClient = hs?.ClientHttpClient; + try { + var res = await httpClient.GetAsync(GetRequestUrl); + if (res.IsSuccessStatusCode) { + if (res.Content.Headers.ContentType.MediaType == "application/json") + GetRequestResult = (await res.Content.ReadFromJsonAsync()).ToJson(); + else + GetRequestResult = await res.Content.ReadAsStringAsync(); + StateHasChanged(); + return; + } + if (res.Content.Headers.ContentType.MediaType == "application/json") + GetRequestResult = $"Error: {res.StatusCode}\n" + (await res.Content.ReadFromJsonAsync()).ToJson(); + else + GetRequestResult = $"Error: {res.StatusCode}\n" + await res.Content.ReadAsStringAsync(); + } + catch (Exception e) { + GetRequestResult = $"Error: {e}"; + } + StateHasChanged(); + } + +} \ No newline at end of file -- cgit 1.4.1