about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared/RoomListComponents
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-01-24 02:31:56 +0100
committerRory& <root@rory.gay>2024-01-24 17:05:25 +0100
commit03313562d21d5db9bf6a14ebbeab80e06c883d3a (patch)
treee000546a2ee8e6a886a7ed9fd01ad674178fb7cb /MatrixRoomUtils.Web/Shared/RoomListComponents
parentMake RMU installable (diff)
downloadMatrixUtils-03313562d21d5db9bf6a14ebbeab80e06c883d3a.tar.xz
MRU->RMU, fixes, cleanup
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/RoomListComponents')
-rw-r--r--MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor63
-rw-r--r--MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListPolicyRoom.razor13
-rw-r--r--MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor60
3 files changed, 0 insertions, 136 deletions
diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
deleted file mode 100644

index 4db25e1..0000000 --- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor +++ /dev/null
@@ -1,63 +0,0 @@ -@using MatrixRoomUtils.Web.Classes.Constants -@using LibMatrix -@using LibMatrix.EventTypes.Spec.State -@using LibMatrix.Homeservers -@using LibMatrix.Responses -@using MatrixRoomUtils.Abstractions -<details> - <summary>@RoomType (@Rooms.Count)</summary> - @foreach (var room in Rooms) { - <div class="room-list-item"> - <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> *@ - @* } *@ - <LinkButton href="@($"/Rooms/{room.Room.RoomId}/Timeline")">View timeline</LinkButton> - <LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/View")">View state</LinkButton> - <LinkButton href="@($"/Rooms/{room.Room.RoomId}/State/Edit")">Edit state</LinkButton> - - @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> -<br/> - -@code { - - [Parameter] - public KeyValuePair<string, List<RoomInfo>> Category { get; set; } - - [Parameter] - public UserProfileResponse? GlobalProfile { get; set; } - - [CascadingParameter] - public AuthenticatedHomeserverGeneric Homeserver { get; set; } = null!; - - private string RoomType => Category.Key; - private List<RoomInfo> Rooms => Category.Value; - - private int RoomVersionDangerLevel(RoomInfo room) { - var creationEvent = room.StateEvents.FirstOrDefault(x => x?.Type == "m.room.create"); - if (creationEvent is null) return 0; - return creationEvent.TypedContent is not RoomCreateEventContent roomVersionContent ? 0 - : RoomConstants.DangerousRoomVersions.Contains(roomVersionContent.RoomVersion) ? 2 - : roomVersionContent.RoomVersion != RoomConstants.RecommendedRoomVersion ? 1 : 0; - } - - public static string GetRoomTypeName(string roomType) { - return roomType switch { - null => "Room", - "m.space" => "Space", - "org.matrix.mjolnir.policy" => "Policy room", - - _ => roomType - }; - } - -} diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListPolicyRoom.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListPolicyRoom.razor deleted file mode 100644
index 7afdc8c..0000000 --- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListPolicyRoom.razor +++ /dev/null
@@ -1,13 +0,0 @@ -@using LibMatrix.RoomTypes -<LinkButton href="@($"/Rooms/{Room.RoomId}/Policies")">Manage policies</LinkButton> - -@code { - - [Parameter] - public GenericRoom Room { get; set; } - - protected override async Task OnInitializedAsync() { - await base.OnInitializedAsync(); - } - -} diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor deleted file mode 100644
index a6c006b..0000000 --- a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor +++ /dev/null
@@ -1,60 +0,0 @@ -@using System.Collections.ObjectModel -@using MatrixRoomUtils.Abstractions -<MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton href="@($"/Rooms/{Space.Room.RoomId}/Space")">Manage space</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton> - -<br/> -<details @ontoggle="SpaceChildrenOpened"> - <summary>@Children.Count children</summary> - @if (_shouldRenderChildren) { - <p>Breadcrumb: @Breadcrumbs</p> - <div style="margin-left: 8px;"> - <RoomList Rooms="Children"></RoomList> - </div> - } -</details> - -@code { - - [Parameter] - 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; - } - - private ObservableCollection<RoomInfo> Children { get; set; } = new(); - - protected override async Task OnInitializedAsync() { - if (Breadcrumbs == null) throw new ArgumentNullException(nameof(Breadcrumbs)); - await Task.Delay(Random.Shared.Next(1000, 10000)); - var rooms = Space.Room.AsSpace.GetChildrenAsync(); - await foreach (var room in rooms) { - if (Breadcrumbs.Contains(room.RoomId)) continue; - var roomInfo = KnownRooms.FirstOrDefault(x => x.Room.RoomId == room.RoomId); - if (roomInfo is null) { - roomInfo = new RoomInfo() { - Room = room - }; - KnownRooms.Add(roomInfo); - } - Children.Add(roomInfo); - } - await base.OnInitializedAsync(); - } - - private bool _shouldRenderChildren = false; - private string? _breadcrumbs; - - private Task SpaceChildrenOpened() { - if (_shouldRenderChildren) return Task.CompletedTask; - _shouldRenderChildren = true; - Console.WriteLine($"[RoomList] Rendering children of {Space.Room.RoomId}"); - return Task.CompletedTask; - } - -}