From 7978f08235ceca22eacae11a88a7703513238cb3 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Sat, 1 Jul 2023 20:51:15 +0200 Subject: Deduplicate some api calls --- .../Pages/RoomState/RoomStateEditorPage.razor | 2 +- .../Pages/RoomState/RoomStateRoomList.razor | 32 ---------------------- .../Pages/RoomState/RoomStateViewerPage.razor | 3 +- MatrixRoomUtils.Web/Pages/Rooms/Index.razor | 5 +++- 4 files changed, 6 insertions(+), 36 deletions(-) delete mode 100644 MatrixRoomUtils.Web/Pages/RoomState/RoomStateRoomList.razor (limited to 'MatrixRoomUtils.Web/Pages') diff --git a/MatrixRoomUtils.Web/Pages/RoomState/RoomStateEditorPage.razor b/MatrixRoomUtils.Web/Pages/RoomState/RoomStateEditorPage.razor index b2d28f6..8b2ff0c 100644 --- a/MatrixRoomUtils.Web/Pages/RoomState/RoomStateEditorPage.razor +++ b/MatrixRoomUtils.Web/Pages/RoomState/RoomStateEditorPage.razor @@ -1,4 +1,4 @@ -@page "/RoomStateViewer/{RoomId}/Edit" +@page "/Rooms/{RoomId}/State/Edit" @using System.Net.Http.Headers @using System.Text.Json @using MatrixRoomUtils.Core.Responses diff --git a/MatrixRoomUtils.Web/Pages/RoomState/RoomStateRoomList.razor b/MatrixRoomUtils.Web/Pages/RoomState/RoomStateRoomList.razor deleted file mode 100644 index 55c44d9..0000000 --- a/MatrixRoomUtils.Web/Pages/RoomState/RoomStateRoomList.razor +++ /dev/null @@ -1,32 +0,0 @@ -@page "/RoomStateViewer" -@inject ILocalStorageService LocalStorage -@inject NavigationManager NavigationManager -

Room state viewer - Room list

-
-@if (Rooms.Count == 0) { -

You are not in any rooms!

- @*

Loading progress: @checkedRoomCount/@totalRoomCount

*@ -} -else { - @foreach (var room in Rooms) { - - - - } -
-} - - - -@code { - public List Rooms { get; set; } = new(); - - protected override async Task OnInitializedAsync() { - await base.OnInitializedAsync(); - var hs = await MRUStorage.GetCurrentSessionOrNavigate(); - if (hs is null) return; - Rooms = (await hs.GetJoinedRooms()).Select(x => x.RoomId).ToList(); - Console.WriteLine("Fetched joined rooms!"); - } - -} \ No newline at end of file diff --git a/MatrixRoomUtils.Web/Pages/RoomState/RoomStateViewerPage.razor b/MatrixRoomUtils.Web/Pages/RoomState/RoomStateViewerPage.razor index a0072ab..09b38f0 100644 --- a/MatrixRoomUtils.Web/Pages/RoomState/RoomStateViewerPage.razor +++ b/MatrixRoomUtils.Web/Pages/RoomState/RoomStateViewerPage.razor @@ -1,4 +1,4 @@ -@page "/RoomStateViewer/{RoomId}" +@page "/Rooms/{RoomId}/State/View" @using System.Net.Http.Headers @using System.Text.Json @using MatrixRoomUtils.Core.Responses @@ -73,7 +73,6 @@ await base.OnInitializedAsync(); var hs = await MRUStorage.GetCurrentSessionOrNavigate(); if (hs is null) return; - RoomId = RoomId.Replace('~', '.'); await LoadStatesAsync(); Console.WriteLine("Policy list editor initialized!"); } diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor index 20ddd0d..932748d 100644 --- a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor +++ b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor @@ -1,18 +1,21 @@ @page "/Rooms" +@using MatrixRoomUtils.Core.StateEventTypes

Room list

@if (Rooms is not null) { - + } @code { private List Rooms { get; set; } + private ProfileResponse GlobalProfile { get; set; } protected override async Task OnInitializedAsync() { var hs = await MRUStorage.GetCurrentSessionOrNavigate(); if (hs is null) return; + GlobalProfile = await hs.GetProfile(hs.WhoAmI.UserId); Rooms = await hs.GetJoinedRooms(); await base.OnInitializedAsync(); -- cgit 1.5.1