about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Pages/Rooms
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-17 17:11:49 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-10-17 17:11:49 +0200
commitc5c3c3506ec10e373d5c0ebb15146e4ed4e36df5 (patch)
treee74107e266ced599100d43c4e5c0823d4292dfdd /MatrixRoomUtils.Web/Pages/Rooms
parentRefactors (diff)
downloadMatrixUtils-c5c3c3506ec10e373d5c0ebb15146e4ed4e36df5.tar.xz
Add profile management page
Diffstat (limited to 'MatrixRoomUtils.Web/Pages/Rooms')
-rw-r--r--MatrixRoomUtils.Web/Pages/Rooms/Create.razor12
-rw-r--r--MatrixRoomUtils.Web/Pages/Rooms/Index.razor16
-rw-r--r--MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor2
-rw-r--r--MatrixRoomUtils.Web/Pages/Rooms/Space.razor8
-rw-r--r--MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor1
-rw-r--r--MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor1
6 files changed, 26 insertions, 14 deletions
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Create.razor b/MatrixRoomUtils.Web/Pages/Rooms/Create.razor
index 5202c40..3225862 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/Create.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/Create.razor
@@ -90,7 +90,7 @@
         <tr>
             <td>Room icon:</td>
             <td>
-                <img src="@hsResolver.ResolveMediaUri(HomeServer.HomeServerDomain, roomAvatarEvent.Url)" style="width: 128px; height: 128px; border-radius: 50%;"/>
+                <img src="@hsResolver.ResolveMediaUri(HomeServer.ServerName, roomAvatarEvent.Url)" style="width: 128px; height: 128px; border-radius: 50%;"/>
                 <div style="display: inline-block; vertical-align: middle;">
                     <FancyTextBox @bind-Value="@roomAvatarEvent.Url"></FancyTextBox><br/>
                     <InputFile OnChange="RoomIconFilePicked"></InputFile>
@@ -135,7 +135,7 @@
                 }
                 else {
                     <details>
-                        <summary>@((creationEvent["m.room.server_acls"].TypedContent as ServerACLEventContent).Allow.Count) allow rules</summary>
+                        <summary>@((creationEvent["m.room.server_acls"].TypedContent as RoomServerACLEventContent).Allow.Count) allow rules</summary>
                         @* <StringListEditor @bind-Items="@serverAcl.Allow"></StringListEditor> *@
                     </details>
                 }
@@ -145,7 +145,7 @@
                 }
                 else {
                     <details>
-                        <summary>@((creationEvent["m.room.server_acls"].TypedContent as ServerACLEventContent).Deny.Count) deny rules</summary>
+                        <summary>@((creationEvent["m.room.server_acls"].TypedContent as RoomServerACLEventContent).Deny.Count) deny rules</summary>
                         @* <StringListEditor @bind-Items="@serverAcl.Allow"></StringListEditor> *@
                     </details>
                 }
@@ -255,9 +255,9 @@
 
     private MatrixException? _matrixException { get; set; }
 
-    private HistoryVisibilityEventContent? historyVisibility => creationEvent?["m.room.history_visibility"].TypedContent as HistoryVisibilityEventContent;
-    private GuestAccessEventContent? guestAccessEvent => creationEvent?["m.room.guest_access"].TypedContent as GuestAccessEventContent;
-    private ServerACLEventContent? serverAcl => creationEvent?["m.room.server_acls"].TypedContent as ServerACLEventContent;
+    private RoomHistoryVisibilityEventContent? historyVisibility => creationEvent?["m.room.history_visibility"].TypedContent as RoomHistoryVisibilityEventContent;
+    private RoomGuestAccessEventContent? guestAccessEvent => creationEvent?["m.room.guest_access"].TypedContent as RoomGuestAccessEventContent;
+    private RoomServerACLEventContent? serverAcl => creationEvent?["m.room.server_acls"].TypedContent as RoomServerACLEventContent;
     private RoomAvatarEventContent? roomAvatarEvent => creationEvent?["m.room.avatar"].TypedContent as RoomAvatarEventContent;
 
     protected override async Task OnInitializedAsync() {
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
index 99e8cbb..69a0ede 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
@@ -3,6 +3,7 @@
 @using LibMatrix.Helpers
 @using LibMatrix.Responses
 @using LibMatrix.EventTypes.Spec.State
+@using LibMatrix
 <h3>Room list</h3>
 
 <p>@Status</p>
@@ -58,10 +59,14 @@
         GlobalProfile = await hs.GetProfileAsync(hs.WhoAmI.UserId);
 
         Status = "Syncing...";
-        SyncResult? sync = null;
+        var syncHelper = new SyncHelper(hs) {
+            Timeout = 0,
+            Filter = filter
+        };
+        // SyncResponse? sync = null;
         string? nextBatch = null;
-        while (sync is null or { Rooms.Join.Count: >= 1}) {
-            sync = await hs.SyncHelper.Sync(since: nextBatch, filter: filter, timeout: 0);
+        var syncs = syncHelper.EnumerateSyncAsync();
+        await foreach (var sync in syncs) {
             nextBatch = sync?.NextBatch ?? nextBatch;
             if (sync is null) continue;
             Console.WriteLine($"Got sync, next batch: {nextBatch}!");
@@ -86,7 +91,12 @@
             Status = $"Got {Rooms.Count} rooms so far! Next batch: {nextBatch}";
             StateHasChanged();
             await Task.Delay(100);
+            if (!syncHelper.IsInitialSync) break;
         }
+        // while (sync is null or { Rooms.Join.Count: >= 1}) {
+            // sync = await syncHelper.SyncAsync(since: nextBatch, filter: filter, timeout: 0);
+            
+        // }
         Console.WriteLine("Sync done!");
         Status = "Sync complete!";
         foreach (var roomInfo in Rooms) {
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor b/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor
index e6f436e..15220da 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/PolicyList.razor
@@ -235,7 +235,7 @@ else {
             var server = servers.ContainsKey(hs) ? servers[hs] : new RemoteHomeServer(userId.Split(':')[1]);
             if (!servers.ContainsKey(hs)) servers.Add(hs, server);
             var profile = await server.GetProfileAsync(userId);
-            avatars.Add(userId, await hsResolver.ResolveMediaUri(server.FullHomeServerDomain, profile.AvatarUrl));
+            avatars.Add(userId, await hsResolver.ResolveMediaUri(server.BaseUrl, profile.AvatarUrl));
             servers.Add(userId, server);
             StateHasChanged();
         }
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Space.razor b/MatrixRoomUtils.Web/Pages/Rooms/Space.razor
index 9474b21..d0236e2 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/Space.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/Space.razor
@@ -3,6 +3,7 @@
 @using LibMatrix.Responses
 @using LibMatrix.RoomTypes
 @using ArcaneLibs.Extensions
+@using LibMatrix
 <h3>Room manager - Viewing Space</h3>
 
 <button onclick="@JoinAllRooms">Join all rooms</button>
@@ -93,10 +94,9 @@
     // await base.OnInitializedAsync();
     }
 
-    private Task JoinAllRooms() {
-        List<Task> tasks = Rooms.Select(room => room.JoinAsync(ServersInSpace.ToArray())).ToList();
-        Task.WaitAll(tasks.ToArray());
-        return Task.CompletedTask;
+    private async Task JoinAllRooms() {
+        List<Task<RoomIdResponse>> tasks = Rooms.Select(room => room.JoinAsync(ServersInSpace.ToArray())).ToList();
+        await Task.WhenAll(tasks);
     }
 
 }
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor b/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor
index f7a6106..e47ba11 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/StateEditor.razor
@@ -2,6 +2,7 @@
 @using LibMatrix.Extensions
 @using LibMatrix.Responses
 @using ArcaneLibs.Extensions
+@using LibMatrix
 @inject ILocalStorageService LocalStorage
 @inject NavigationManager NavigationManager
 <h3>Room state editor - Editing @RoomId</h3>
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor b/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor
index 6e8fe2f..e9c5da1 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/StateViewer.razor
@@ -2,6 +2,7 @@
 @using LibMatrix.Extensions
 @using LibMatrix.Responses
 @using ArcaneLibs.Extensions
+@using LibMatrix
 @inject ILocalStorageService LocalStorage
 @inject NavigationManager NavigationManager
 <h3>Room state viewer - Viewing @RoomId</h3>