From 41c5a84dacfd036b8d8f01f72226ac5a519995e3 Mon Sep 17 00:00:00 2001 From: Rory& Date: Tue, 14 May 2024 17:49:09 +0200 Subject: Organise tools somewhat, set proper icons for nav menu --- MatrixUtils.Web/Pages/Labs/Client/Index.razor | 72 +++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 MatrixUtils.Web/Pages/Labs/Client/Index.razor (limited to 'MatrixUtils.Web/Pages/Labs/Client/Index.razor') diff --git a/MatrixUtils.Web/Pages/Labs/Client/Index.razor b/MatrixUtils.Web/Pages/Labs/Client/Index.razor new file mode 100644 index 0000000..5b489b0 --- /dev/null +++ b/MatrixUtils.Web/Pages/Labs/Client/Index.razor @@ -0,0 +1,72 @@ +@page "/Labs/Client" +@using LibMatrix +@using MatrixUtils.Abstractions +@using MatrixUtils.Web.Pages.Client.ClientComponents +@using System.Collections.ObjectModel + +

Client

+ + +@foreach (var client in Clients) { + + @client.Homeserver.WhoAmI.UserId + +} + + + +@* @foreach (var client in Clients) { *@ +@*
*@ +@* @client.Homeserver.UserId - @client.SyncWrapper.Status *@ +@*
*@ +@* } *@ + +@if (SelectedClient != null) { +
+ +
+} + +@code { + + private static readonly ObservableCollection Clients = []; + private static ClientContext _selectedClient; + + private ClientContext SelectedClient { + get => _selectedClient; + set { + _selectedClient = value; + StateHasChanged(); + } + } + + protected override async Task OnInitializedAsync() { + var tokens = await RMUStorage.GetAllTokens(); + var tasks = tokens.Select(async token => { + try { + var cc = new ClientContext() { + Homeserver = await RMUStorage.GetSession(token) + }; + cc.SyncWrapper = new ClientSyncWrapper(cc.Homeserver); + +#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + cc.SyncWrapper.Start(); +#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + + Clients.Add(cc); + StateHasChanged(); + } + catch { } + }).ToList(); + await Task.WhenAll(tasks); + } + + public class ClientContext { + public AuthenticatedHomeserverGeneric Homeserver { get; set; } + public ClientSyncWrapper SyncWrapper { get; set; } + + public RoomInfo? SelectedRoom { get; set; } + } + +} + -- cgit 1.4.1