blob: a113f0b6d66a41b63f6e1d35e9ae224b73210828 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<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 List<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.GetRoomsAsync();
await foreach (var room in rooms) {
if (Breadcrumbs.Contains(room.RoomId)) continue;
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();
}
private bool _shouldRenderChildren = false;
private string? _breadcrumbs;
private async Task SpaceChildrenOpened() {
if (_shouldRenderChildren) return;
_shouldRenderChildren = true;
Console.WriteLine($"[RoomList] Rendering children of {Space.Room.RoomId}");
}
}
|