diff --git a/MatrixUtils.Web/Pages/User/Profile.razor b/MatrixUtils.Web/Pages/User/Profile.razor
index 8cffaab..deebdaf 100644
--- a/MatrixUtils.Web/Pages/User/Profile.razor
+++ b/MatrixUtils.Web/Pages/User/Profile.razor
@@ -2,7 +2,9 @@
@using LibMatrix.Homeservers
@using LibMatrix.EventTypes.Spec.State
@using ArcaneLibs.Extensions
+@using LibMatrix
@using LibMatrix.Responses
+@using MatrixUtils.Abstractions
<h3>Manage Profile - @Homeserver?.WhoAmI?.UserId</h3>
<hr/>
@@ -28,6 +30,35 @@
@* <details> *@
<h4>Room profiles<hr></h4>
+ @foreach (var room in Rooms) {
+ <details class="details-compact">
+ <summary style="@(room.OwnMembership?.DisplayName == OldProfile.DisplayName && room.OwnMembership?.AvatarUrl == OldProfile.AvatarUrl ? "" : "#ffff0033")">
+ <div style="display: inline-block; width: calc(100% - 50px); vertical-align: middle; margin-top: -8px; margin-bottom: -8px;">
+ <CascadingValue Value="OldProfile">
+ <RoomListItem ShowOwnProfile="true" RoomInfo="@room" OwnMemberState="@room.OwnMembership"></RoomListItem>
+ </CascadingValue>
+ </div>
+ </summary>
+ @if (room.OwnMembership is not null) {
+ <img src="@Homeserver.ResolveMediaUri(room.OwnMembership.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="@(room.OwnMembership.DisplayName == OldProfile.DisplayName ? "" : "#ffff0033")" @bind-Value="@room.OwnMembership.DisplayName"></FancyTextBox><br/>
+ <span>Avatar URL: </span><FancyTextBox BackgroundColor="@(room.OwnMembership.AvatarUrl == OldProfile.AvatarUrl ? "" : "#ffff0033")" @bind-Value="@room.OwnMembership.AvatarUrl"></FancyTextBox>
+ <InputFile OnChange="@(ifcea => RoomAvatarChanged(ifcea, room.Room.RoomId))"></InputFile><br/>
+ <LinkButton OnClick="@(() => UpdateRoomProfile(room.Room.RoomId))">Update profile</LinkButton>
+ </div>
+ <br/>
+ @if (!string.IsNullOrWhiteSpace(Status)) {
+ <p>@Status</p>
+ }
+ }
+ else {
+ <p>Something went wrong, own membership is missing...</p>
+ }
+ </details>
+ <br/>
+ }
+
@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>
@@ -63,6 +94,7 @@
}
}
+ private List<RoomInfo> Rooms { get; set; } = new();
private Dictionary<string, RoomMemberEventContent> RoomProfiles { get; set; } = new();
private Dictionary<string, string> RoomNames { get; set; } = new();
@@ -76,6 +108,28 @@
Status = "Loading room profiles...";
var roomProfiles = Homeserver.GetRoomProfilesAsync();
await foreach (var (roomId, roomProfile) in roomProfiles) {
+ var room = Homeserver.GetRoom(roomId);
+ var roomNameTask = room.GetNameOrFallbackAsync();
+ var roomIconTask = room.GetAvatarUrlAsync();
+ var roomInfo = new RoomInfo() {
+ Room = room,
+ OwnMembership = roomProfile
+ };
+ try {
+ roomInfo.RoomIcon = (await roomIconTask).Url;
+ }
+ catch (MatrixException e) {
+ if (e is not { ErrorCode: "M_NOT_FOUND" }) throw;
+ }
+
+ try {
+ roomInfo.RoomName = await roomNameTask;
+ }
+ catch (MatrixException e) {
+ if (e is not { ErrorCode: "M_NOT_FOUND" }) throw;
+ }
+
+ Rooms.Add(roomInfo);
// Status = $"Got profile for {roomId}...";
RoomProfiles[roomId] = roomProfile; //.DeepClone();
}
@@ -87,7 +141,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;
|