about summary refs log tree commit diff
path: root/MatrixUtils.Web/Pages/Client/Index.razor
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-05-03 19:40:00 +0200
committerRory& <root@rory.gay>2024-05-03 19:40:00 +0200
commit222f475dfd662980d5e0b9f27efa951f91604364 (patch)
tree71777992828134ee89249a7e37339bc4aa89ba86 /MatrixUtils.Web/Pages/Client/Index.razor
parentCleanup, work on index2, some tooling updates (diff)
downloadMatrixUtils-222f475dfd662980d5e0b9f27efa951f91604364.tar.xz
All kinds of changes
Diffstat (limited to 'MatrixUtils.Web/Pages/Client/Index.razor')
-rw-r--r--MatrixUtils.Web/Pages/Client/Index.razor72
1 files changed, 72 insertions, 0 deletions
diff --git a/MatrixUtils.Web/Pages/Client/Index.razor b/MatrixUtils.Web/Pages/Client/Index.razor
new file mode 100644
index 0000000..2a9a327
--- /dev/null
+++ b/MatrixUtils.Web/Pages/Client/Index.razor
@@ -0,0 +1,72 @@
+@page "/Client"
+@using LibMatrix
+@using MatrixUtils.Abstractions
+@using MatrixUtils.Web.Pages.Client.ClientComponents
+@using System.Collections.ObjectModel
+
+<h3>Client</h3>
+
+
+@foreach (var client in Clients) {
+    <LinkButton Color="@(SelectedClient == client ? "#ff00ff" : "")" OnClick="@(async () => SelectedClient = client)">
+        @client.Homeserver.WhoAmI.UserId
+    </LinkButton>
+}
+<ClientStatusList Data="@Clients"></ClientStatusList>
+
+
+@* @foreach (var client in Clients) { *@
+@*     <div class="card"> *@
+@*         <span>@client.Homeserver.UserId - @client.SyncWrapper.Status</span> *@
+@*     </div> *@
+@* } *@
+
+@if (SelectedClient != null) {
+    <div class="card">
+        <MatrixClient Data="@SelectedClient"/>
+    </div>
+}
+
+@code {
+
+    private static readonly ObservableCollection<ClientContext> 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; }
+    }
+
+}
+