about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Pages/User
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixRoomUtils.Web/Pages/User')
-rw-r--r--MatrixRoomUtils.Web/Pages/User/DMManager.razor2
-rw-r--r--MatrixRoomUtils.Web/Pages/User/DMSpaceStages/DMSpaceStage2.razor5
-rw-r--r--MatrixRoomUtils.Web/Pages/User/DMSpaceStages/DMSpaceStage3.razor6
-rw-r--r--MatrixRoomUtils.Web/Pages/User/Profile.razor78
4 files changed, 51 insertions, 40 deletions
diff --git a/MatrixRoomUtils.Web/Pages/User/DMManager.razor b/MatrixRoomUtils.Web/Pages/User/DMManager.razor
index 1b28516..a327793 100644
--- a/MatrixRoomUtils.Web/Pages/User/DMManager.razor
+++ b/MatrixRoomUtils.Web/Pages/User/DMManager.razor
@@ -1,7 +1,7 @@
 @page "/User/DirectMessages"
-@using LibMatrix.Homeservers
 @using LibMatrix.EventTypes.Spec.State
 @using LibMatrix.Responses
+@using MatrixRoomUtils.Abstractions
 <h3>Direct Messages</h3>
 <hr/>
 
diff --git a/MatrixRoomUtils.Web/Pages/User/DMSpaceStages/DMSpaceStage2.razor b/MatrixRoomUtils.Web/Pages/User/DMSpaceStages/DMSpaceStage2.razor
index 553f46d..60c68ac 100644
--- a/MatrixRoomUtils.Web/Pages/User/DMSpaceStages/DMSpaceStage2.razor
+++ b/MatrixRoomUtils.Web/Pages/User/DMSpaceStages/DMSpaceStage2.razor
@@ -7,6 +7,7 @@
 @using MatrixRoomUtils.LibDMSpace.StateEvents
 @using ArcaneLibs.Extensions
 @using System.Text.Json.Serialization
+@using MatrixRoomUtils.Abstractions
 <b>
     <u>DM Space setup tool - stage 2: Fix DM room attribution</u>
 </b>
@@ -185,9 +186,9 @@ else {
         }
         catch { }
 
-        var membersEnum = room.GetMembersAsync();
+        var membersEnum = room.GetMembersEnumerableAsync(true);
         await foreach (var member in membersEnum)
-            if (member.TypedContent is RoomMemberEventContent memberEvent && !string.IsNullOrWhiteSpace(memberEvent.Membership) && memberEvent.Membership == "join")
+            if (member.TypedContent is RoomMemberEventContent memberEvent)
                 roomMembers[roomInfo].Add(new() { DisplayName = memberEvent.DisplayName, AvatarUrl = memberEvent.AvatarUrl, Id = member.StateKey });
 
         if (string.IsNullOrWhiteSpace(roomInfo.RoomName) || roomInfo.RoomName == room.RoomId) {
diff --git a/MatrixRoomUtils.Web/Pages/User/DMSpaceStages/DMSpaceStage3.razor b/MatrixRoomUtils.Web/Pages/User/DMSpaceStages/DMSpaceStage3.razor
index 854b09c..42573e6 100644
--- a/MatrixRoomUtils.Web/Pages/User/DMSpaceStages/DMSpaceStage3.razor
+++ b/MatrixRoomUtils.Web/Pages/User/DMSpaceStages/DMSpaceStage3.razor
@@ -7,6 +7,8 @@
 @using MatrixRoomUtils.LibDMSpace.StateEvents
 @using ArcaneLibs.Extensions
 @using System.Text.Json.Serialization
+@using MatrixRoomUtils.Abstractions
+
 <b>
     <u>DM Space setup tool - stage 3: Preview space layout</u>
 </b>
@@ -154,9 +156,9 @@ else {
         }
         catch { }
 
-        var membersEnum = room.GetMembersAsync();
+        var membersEnum = room.GetMembersEnumerableAsync(true);
         await foreach (var member in membersEnum)
-            if (member.TypedContent is RoomMemberEventContent memberEvent && !string.IsNullOrWhiteSpace(memberEvent.Membership) && memberEvent.Membership == "join")
+            if (member.TypedContent is RoomMemberEventContent memberEvent)
                 roomMembers.Add(new() { DisplayName = memberEvent.DisplayName, AvatarUrl = memberEvent.AvatarUrl, Id = member.StateKey });
 
         if (string.IsNullOrWhiteSpace(roomInfo.RoomName) || roomInfo.RoomName == room.RoomId) {
diff --git a/MatrixRoomUtils.Web/Pages/User/Profile.razor b/MatrixRoomUtils.Web/Pages/User/Profile.razor
index ae3fb76..73d7c6e 100644
--- a/MatrixRoomUtils.Web/Pages/User/Profile.razor
+++ b/MatrixRoomUtils.Web/Pages/User/Profile.razor
@@ -9,40 +9,43 @@
 @if (NewProfile is not null) {
     <h4>Profile</h4>
     <hr/>
-
-    <img src="@Homeserver.ResolveMediaUri(NewProfile.AvatarUrl)" style="width: 96px; height: 96px; border-radius: 50%; object-fit: cover;"/>
-    <div style="display: inline-block; vertical-align: middle;">
-        <span>Display name: </span><FancyTextBox @bind-Value="@NewProfile.DisplayName"></FancyTextBox><br/>
-        <span>Avatar URL: </span><FancyTextBox @bind-Value="@NewProfile.AvatarUrl"></FancyTextBox>
-        <InputFile OnChange="@AvatarChanged"></InputFile><br/>
-        <LinkButton OnClick="@(() => UpdateProfile())">Update profile</LinkButton>
-        <LinkButton OnClick="@(() => UpdateProfile(true))">Update profile (restore room overrides)</LinkButton>
+    <div>
+        <img src="@Homeserver.ResolveMediaUri(NewProfile.AvatarUrl)" style="width: 96px; height: 96px; border-radius: 50%; object-fit: cover;"/>
+        <div style="display: inline-block; vertical-align: middle;">
+            <span>Display name: </span><FancyTextBox @bind-Value="@NewProfile.DisplayName"></FancyTextBox><br/>
+            <span>Avatar URL: </span><FancyTextBox @bind-Value="@NewProfile.AvatarUrl"></FancyTextBox>
+            <InputFile OnChange="@AvatarChanged"></InputFile><br/>
+            <LinkButton OnClick="@(() => UpdateProfile())">Update profile</LinkButton>
+            <LinkButton OnClick="@(() => UpdateProfile(true))">Update profile (restore room overrides)</LinkButton>
+        </div>
     </div>
     @if (!string.IsNullOrWhiteSpace(Status)) {
         <p>@Status</p>
     }
 
-    <details>
-        <summary style="font-size: 1.5rem;">Room profiles<hr></summary>
-
-        @foreach (var (roomId, roomProfile) in RoomProfiles.OrderBy(x=>RoomNames.TryGetValue(x.Key, out var _name) ? _name : x.Key)) {
-            <details class="details-compact">
-                <summary style="@(roomProfile.DisplayName == OldProfile.DisplayName && roomProfile.AvatarUrl == OldProfile.AvatarUrl ? "" : "#ffff0033")">@(RoomNames.TryGetValue(roomId, out var name) ? name : roomId)</summary>
-                <img src="@Homeserver.ResolveMediaUri(roomProfile.AvatarUrl)" style="width: 96px; height: 96px; border-radius: 50%; object-fit: cover;"/>
-                <div style="display: inline-block; vertical-align: middle;">
-                    <span>Display name: </span><FancyTextBox BackgroundColor="@(roomProfile.DisplayName == OldProfile.DisplayName ? "" : "#ffff0033")" @bind-Value="@roomProfile.DisplayName"></FancyTextBox><br/>
-                    <span>Avatar URL: </span><FancyTextBox BackgroundColor="@(roomProfile.AvatarUrl == OldProfile.AvatarUrl ? "" : "#ffff0033")" @bind-Value="@roomProfile.AvatarUrl"></FancyTextBox>
-                    <InputFile OnChange="@(ifcea => RoomAvatarChanged(ifcea, roomId))"></InputFile><br/>
-                    <LinkButton OnClick="@(() => UpdateRoomProfile(roomId))">Update profile</LinkButton>
-                </div>
-                <br/>
-                @if (!string.IsNullOrWhiteSpace(Status)) {
-                    <p>@Status</p>
-                }
-            </details>
+    <br/>
+
+    @* <details> *@
+    <h4>Room profiles<hr></h4>
+
+    @foreach (var (roomId, roomProfile) in RoomProfiles.OrderBy(x => RoomNames.TryGetValue(x.Key, out var _name) ? _name : x.Key)) {
+        <details class="details-compact">
+            <summary style="@(roomProfile.DisplayName == OldProfile.DisplayName && roomProfile.AvatarUrl == OldProfile.AvatarUrl ? "" : "#ffff0033")">@(RoomNames.TryGetValue(roomId, out var name) ? name : roomId)</summary>
+            <img src="@Homeserver.ResolveMediaUri(roomProfile.AvatarUrl)" style="width: 96px; height: 96px; border-radius: 50%; object-fit: cover;"/>
+            <div style="display: inline-block; vertical-align: middle;">
+                <span>Display name: </span><FancyTextBox BackgroundColor="@(roomProfile.DisplayName == OldProfile.DisplayName ? "" : "#ffff0033")" @bind-Value="@roomProfile.DisplayName"></FancyTextBox><br/>
+                <span>Avatar URL: </span><FancyTextBox BackgroundColor="@(roomProfile.AvatarUrl == OldProfile.AvatarUrl ? "" : "#ffff0033")" @bind-Value="@roomProfile.AvatarUrl"></FancyTextBox>
+                <InputFile OnChange="@(ifcea => RoomAvatarChanged(ifcea, roomId))"></InputFile><br/>
+                <LinkButton OnClick="@(() => UpdateRoomProfile(roomId))">Update profile</LinkButton>
+            </div>
             <br/>
-        }
-    </details>
+            @if (!string.IsNullOrWhiteSpace(Status)) {
+                <p>@Status</p>
+            }
+        </details>
+        <br/>
+    }
+    // </details>
 }
 
 @code {
@@ -54,7 +57,10 @@
 
     private string? Status {
         get => _status;
-        set { _status = value; StateHasChanged(); }
+        set {
+            _status = value;
+            StateHasChanged();
+        }
     }
 
     private Dictionary<string, RoomMemberEventContent> RoomProfiles { get; set; } = new();
@@ -65,14 +71,15 @@
         if (Homeserver is null) return;
         Status = "Loading global profile...";
         if (Homeserver.WhoAmI?.UserId is null) return;
-        NewProfile = (await Homeserver.GetProfileAsync(Homeserver.WhoAmI.UserId)).DeepClone();
-        OldProfile = (await Homeserver.GetProfileAsync(Homeserver.WhoAmI.UserId)).DeepClone();
+        NewProfile = (await Homeserver.GetProfileAsync(Homeserver.WhoAmI.UserId)); //.DeepClone();
+        OldProfile = (await Homeserver.GetProfileAsync(Homeserver.WhoAmI.UserId)); //.DeepClone();
         Status = "Loading room profiles...";
         var roomProfiles = Homeserver.GetRoomProfilesAsync();
         await foreach (var (roomId, roomProfile) in roomProfiles) {
             // Status = $"Got profile for {roomId}...";
-            RoomProfiles[roomId] = roomProfile.DeepClone();
+            RoomProfiles[roomId] = roomProfile; //.DeepClone();
         }
+
         StateHasChanged();
         Status = "Room profiles loaded, loading room names...";
 
@@ -80,6 +87,7 @@
             var name = await x.GetNameOrFallbackAsync();
             return new KeyValuePair<string, string?>(x.RoomId, name);
         }).ToAsyncEnumerable();
+        
         await foreach (var (roomId, roomName) in roomNameTasks) {
             // Status = $"Got room name for {roomId}: {roomName}";
             RoomNames[roomId] = roomName;
@@ -106,13 +114,14 @@
         StateHasChanged();
         await OnInitializedAsync();
     }
+
     private async Task RoomAvatarChanged(InputFileChangeEventArgs arg, string roomId) {
         var res = await Homeserver.UploadFile(arg.File.Name, arg.File.OpenReadStream(Int64.MaxValue), arg.File.ContentType);
         Console.WriteLine(res);
         RoomProfiles[roomId].AvatarUrl = res;
         StateHasChanged();
     }
-    
+
     private async Task UpdateRoomProfile(string roomId) {
         Status = "Busy processing room profile update, please do not leave this page...";
         StateHasChanged();
@@ -122,5 +131,4 @@
         StateHasChanged();
     }
 
-}
-
+}
\ No newline at end of file