From d0d11db2209a8be65c27e15ca9d8a3b594f1a352 Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 23 Feb 2024 13:57:06 +0100 Subject: Add eons of work because I forgot to push --- MatrixUtils.Web/Pages/Rooms/Index2.razor | 85 ++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 MatrixUtils.Web/Pages/Rooms/Index2.razor (limited to 'MatrixUtils.Web/Pages/Rooms/Index2.razor') diff --git a/MatrixUtils.Web/Pages/Rooms/Index2.razor b/MatrixUtils.Web/Pages/Rooms/Index2.razor new file mode 100644 index 0000000..ae31126 --- /dev/null +++ b/MatrixUtils.Web/Pages/Rooms/Index2.razor @@ -0,0 +1,85 @@ +@page "/Rooms2" +@using LibMatrix.Responses +@using System.Collections.ObjectModel +@using System.ComponentModel +@using MatrixUtils.Abstractions +@using MatrixUtils.Web.Pages.Rooms.Index2Components +@inject ILogger logger +

Room list

+ + +@if (Data.Homeserver is null || Data.GlobalProfile is null) { +

Creating homeserver instance and fetching global profile...

+ return; +} + +
+ Main + DMs + By room type +
+
+ + @switch (SelectedTab) { + case Tab.Main: +

Main tab

+ + break; + case Tab.DMs: +

DMs tab

+ break; + case Tab.ByRoomType: +

By room type tab

+ break; + default: + throw new InvalidEnumArgumentException(); + } +
+
+ +@* Create new room *@ + + +@code { + + private Tab SelectedTab { + get => _selectedTab; + set { + _selectedTab = value; + StateHasChanged(); + } + } + + public RoomListViewData Data { get; set; } = new RoomListViewData(); + + protected override async Task OnInitializedAsync() { + Data.Homeserver = await RMUStorage.GetCurrentSessionOrNavigate(); + if (Data.Homeserver is null) return; + var rooms = await Data.Homeserver.GetJoinedRooms(); + Data.GlobalProfile = await Data.Homeserver.GetProfileAsync(Data.Homeserver.WhoAmI.UserId); + + foreach (var room in rooms) { + Data.Rooms.Add(new RoomInfo(room)); + } + StateHasChanged(); + + await base.OnInitializedAsync(); + } + + private Tab _selectedTab = Tab.Main; + + private enum Tab { + Main, + DMs, + ByRoomType + } + + public class RoomListViewData { + public ObservableCollection Rooms { get; } = []; + + public UserProfileResponse? GlobalProfile { get; set; } + + public AuthenticatedHomeserverGeneric? Homeserver { get; set; } + } + +} \ No newline at end of file -- cgit 1.4.1