diff options
author | Emma@Rory& <root@rory.gay> | 2023-07-24 20:56:42 +0200 |
---|---|---|
committer | Emma@Rory& <root@rory.gay> | 2023-07-24 20:56:42 +0200 |
commit | 5495a35403d285007d67f503042720302efdf94c (patch) | |
tree | 3db4dc545ce3ad252f82a577ecad4150320c1ba3 /MatrixRoomUtils.Web/Shared/RoomListComponents | |
parent | Change max line width from 120 to 180 (diff) | |
download | MatrixUtils-5495a35403d285007d67f503042720302efdf94c.tar.xz |
Code cleanup
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/RoomListComponents')
-rw-r--r-- | MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor | 16 | ||||
-rw-r--r-- | MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor | 18 |
2 files changed, 23 insertions, 11 deletions
diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor index 709f2d7..b798d49 100644 --- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor +++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor @@ -6,13 +6,14 @@ @foreach (var room in rooms) { <div class="room-list-item"> <RoomListItem RoomInfo="@room" ShowOwnProfile="@(roomType == "Room")"></RoomListItem> - @if (RoomVersionDangerLevel(room) != 0) { - <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton Color="@(RoomVersionDangerLevel(room) == 2 ? "#ff0000" : "#ff8800")" href="@($"/Rooms/Create?Import={room.Room.RoomId}")">Upgrade room</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton> - } + @* @if (RoomVersionDangerLevel(room) != 0 && *@ + @* (room.StateEvents.FirstOrDefault(x=>x.Type == "m.room.power_levels")?.TypedContent is RoomPowerLevelEventData powerLevels && powerLevels.UserHasPermission(HomeServer.UserId, "m.room.tombstone"))) { *@ + @* <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton Color="@(RoomVersionDangerLevel(room) == 2 ? "#ff0000" : "#ff8800")" href="@($"/Rooms/Create?Import={room.Room.RoomId}")">Upgrade room</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton> *@ + @* } *@ <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton href="@($"/Rooms/{room.Room.RoomId}/Timeline")">View timeline</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton> <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/View")">View state</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton> <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/Edit")">Edit state</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton> - + @if (roomType == "Space") { <RoomListSpace Space="@room"></RoomListSpace> } @@ -25,10 +26,13 @@ [Parameter] public KeyValuePair<string, List<RoomInfo>> Category { get; set; } - + [Parameter] public ProfileResponseEventData? GlobalProfile { get; set; } + [CascadingParameter] + public AuthenticatedHomeServer HomeServer { get; set; } = null!; + private string roomType => Category.Key; private List<RoomInfo> rooms => Category.Value; @@ -42,4 +46,4 @@ return 0; } -} \ No newline at end of file +} diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor index 5153658..a113f0b 100644 --- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor +++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor @@ -1,4 +1,4 @@ -<LinkButton href="@($"/Rooms/{Space.Room.RoomId}/Space")">Manage space</LinkButton> +<MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton href="@($"/Rooms/{Space.Room.RoomId}/Space")">Manage space</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton> <br/> <details @ontoggle="SpaceChildrenOpened"> @@ -17,6 +17,9 @@ public RoomInfo Space { get; set; } [Parameter, CascadingParameter] + public List<RoomInfo> KnownRooms { get; set; } = new(); + + [Parameter, CascadingParameter] public string? Breadcrumbs { get => _breadcrumbs + Space.Room.RoomId; set => _breadcrumbs = value; @@ -30,9 +33,14 @@ var rooms = Space.Room.AsSpace.GetRoomsAsync(); await foreach (var room in rooms) { if (Breadcrumbs.Contains(room.RoomId)) continue; - Children.Add(new() { - Room = room - }); + RoomInfo roomInfo = KnownRooms.FirstOrDefault(x => x.Room.RoomId == room.RoomId); + if (roomInfo is null) { + roomInfo = new() { + Room = room + }; + KnownRooms.Add(roomInfo); + } + Children.Add(roomInfo); } await base.OnInitializedAsync(); } @@ -46,4 +54,4 @@ Console.WriteLine($"[RoomList] Rendering children of {Space.Room.RoomId}"); } -} \ No newline at end of file +} |