about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Shared/RoomListComponents
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-14 22:26:39 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-06-14 22:26:39 +0200
commitb48f78a381058c188ed61e6f372fbf86d95ad2f9 (patch)
tree178e5d85a92da68b42ffcc68cbbba9b8ea3c40fd /MatrixRoomUtils.Web/Shared/RoomListComponents
parentChange syntax style (diff)
downloadMatrixUtils-b48f78a381058c188ed61e6f372fbf86d95ad2f9.tar.xz
Add changes
Diffstat (limited to 'MatrixRoomUtils.Web/Shared/RoomListComponents')
-rw-r--r--MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor24
-rw-r--r--MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor42
2 files changed, 66 insertions, 0 deletions
diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
new file mode 100644

index 0000000..ecdcc68 --- /dev/null +++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListCategory.razor
@@ -0,0 +1,24 @@ +<details> + <summary>@roomType (@rooms.Count)</summary> + @foreach (var room in rooms) { + <div class="room-list-item"> + <RoomListItem Room="@room" ShowOwnProfile="@(roomType == "Room")"></RoomListItem> + <MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton href="@($"/Rooms/{room.RoomId}/Timeline")">View timeline</MatrixRoomUtils.Web.Shared.SimpleComponents.LinkButton> + + @if (roomType == "Space") { + <RoomListSpace Space="@room"></RoomListSpace> + } + </div> + } +</details> +<br/> + +@code { + + [Parameter] + public KeyValuePair<string, List<Room>> Category { get; set; } + + private string roomType => Category.Key; + private List<Room> rooms => Category.Value; + +} \ No newline at end of file diff --git a/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor new file mode 100644
index 0000000..c90ae8f --- /dev/null +++ b/MatrixRoomUtils.Web/Shared/RoomListComponents/RoomListSpace.razor
@@ -0,0 +1,42 @@ +<LinkButton href="@($"/Rooms/{Space.RoomId}/Space")">Manage space</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 Room Space { get; set; } + + [Parameter, CascadingParameter] + public string? Breadcrumbs { + get => _breadcrumbs + Space.RoomId; + set => _breadcrumbs = value; + } + + private List<Room> Children { get; set; } = new(); + + protected override async Task OnInitializedAsync() { + if (Breadcrumbs == null) throw new ArgumentNullException(nameof(Breadcrumbs)); + Children = (await Space.AsSpace.GetRoomsAsync()).Where(x => !Breadcrumbs.Contains(x.RoomId)).ToList(); + await base.OnInitializedAsync(); + } + + private bool _shouldRenderChildren = false; + private string? _breadcrumbs; + + private async Task SpaceChildrenOpened() { + if (_shouldRenderChildren) return; + _shouldRenderChildren = true; + Console.WriteLine($"[RoomList] Rendering children of {Space.RoomId}"); + } + +} \ No newline at end of file