diff options
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/RoomListComponents')
-rw-r--r-- | MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor index cbe542a..55ffc1e 100644 --- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor +++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor @@ -4,10 +4,10 @@ @using LibMatrix.Homeservers @using LibMatrix.Responses <details> - <summary>@roomType (@rooms.Count)</summary> - @foreach (var room in rooms) { + <summary>@RoomType (@Rooms.Count)</summary> + @foreach (var room in Rooms) { <div class="room-list-item"> - <RoomListItem RoomInfo="@room" ShowOwnProfile="@(roomType == "Room")"></RoomListItem> + <RoomListItem RoomInfo="@room" ShowOwnProfile="@(RoomType == "Room")"></RoomListItem> @* @if (RoomVersionDangerLevel(room) != 0 && *@ @* (room.StateEvents.FirstOrDefault(x=>x.Type == "m.room.power_levels")?.TypedContent is RoomPowerLevelEventContent 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> *@ @@ -16,9 +16,12 @@ <LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/View")">View state</LinkButton> <LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/Edit")">Edit state</LinkButton> - @if (roomType == "Space") { + @if (room.CreationEventContent?.Type == "m.space") { <RoomListSpace Space="@room"></RoomListSpace> } + else if (room.CreationEventContent?.Type == "support.feline.policy.lists.msc.v1" || RoomType == "org.matrix.mjolnir.policy") { + <LinkButton href="@($"/Rooms/{room.Room.RoomId}/Policies")">Manage policies</LinkButton> + } </div> } </details> @@ -35,8 +38,8 @@ [CascadingParameter] public AuthenticatedHomeserverGeneric Homeserver { get; set; } = null!; - private string roomType => Category.Key; - private List<RoomInfo> rooms => Category.Value; + private string RoomType => Category.Key; + private List<RoomInfo> Rooms => Category.Value; private int RoomVersionDangerLevel(RoomInfo room) { var roomVersion = room.StateEvents.FirstOrDefault(x => x.Type == "m.room.create"); @@ -45,5 +48,13 @@ : RoomConstants.DangerousRoomVersions.Contains(roomVersionContent.RoomVersion) ? 2 : roomVersionContent.RoomVersion != RoomConstants.RecommendedRoomVersion ? 1 : 0; } + + public static string GetRoomTypeName(string roomType) { + return roomType switch { + "Room" => "Rooms", + "org.matrix.mjolnir.policy" => "Policies", + _ => roomType + }; + } } |