From 9319fe76c56b79e0933c09280fe32658c2f176c7 Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 5 Apr 2024 19:01:39 +0200 Subject: Cleanup, work on index2, some tooling updates --- .../Index2Components/RoomsIndex2MainTab.razor | 90 ++++++++++++---------- 1 file changed, 51 insertions(+), 39 deletions(-) (limited to 'MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor') diff --git a/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor b/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor index 2b7c5ac..b163a52 100644 --- a/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor +++ b/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor @@ -31,11 +31,17 @@
Uncategorised rooms @foreach (var space in GetTopLevelSpaces()) { - @RecursingSpaceChildren(space) + @* @RecursingSpaceChildren(space) *@ + }

Placeholder for rooms list...

+ @if (SelectedSpace != null) { + foreach (var room in GetSpaceChildRooms(SelectedSpace)) { +

@room.RoomName

+ } + }
@@ -116,48 +122,54 @@ var childSpaces = children.Where(x => x.RoomType == "m.space").ToList(); return childSpaces; } + + private List GetSpaceChildRooms(RoomInfo space) { + var children = GetSpaceChildren(space); + var childRooms = children.Where(x => x.RoomType != "m.space").ToList(); + return childRooms; + } private RoomInfo? SelectedSpace { get; set; } private List OpenedSpaces { get; set; } = new List(); - private RenderFragment RecursingSpaceChildren(RoomInfo space, List? parents = null, int depth = 0) { - parents ??= []; - var totalSw = Stopwatch.StartNew(); - var children = GetSpaceChildSpaces(space); - - var randomColor = RandomNumberGenerator.GetBytes(3).Append((byte)0x33).ToArray().AsHexString().Replace(" ", ""); - var isExpanded = OpenedSpaces.Contains(space); - - // Console.WriteLine($"RecursingSpaceChildren::FetchData - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); - - // var renderSw = Stopwatch.StartNew(); - var rf = new RenderFragment(builder => { - builder.OpenElement(0, "div"); - //space list entry render fragment - // builder.AddContent(1, SpaceListEntry(space)); - builder.OpenComponent(1); - builder.AddAttribute(2, "Space", space); - builder.AddAttribute(2, "OpenedSpaces", OpenedSpaces); - builder.CloseComponent(); - builder.CloseElement(); - //space children render fragment - if (isExpanded) { - builder.OpenElement(2, "div"); - builder.AddAttribute(3, "style", "padding-left: 10px;"); - foreach (var child in children) { - builder.AddContent(4, RecursingSpaceChildren(child, parents.Append(space).ToList(), depth + 1)); - } - - builder.CloseElement(); - } - }); - - // Console.WriteLine($"RecursingSpaceChildren::Render - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {renderSw.Elapsed}"); - if (totalSw.ElapsedMilliseconds > 20) - Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); - // Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); - return rf; - } + // private RenderFragment RecursingSpaceChildren(RoomInfo space, List? parents = null, int depth = 0) { + // parents ??= []; + // var totalSw = Stopwatch.StartNew(); + // var children = GetSpaceChildSpaces(space); + // + // var randomColor = RandomNumberGenerator.GetBytes(3).Append((byte)0x33).ToArray().AsHexString().Replace(" ", ""); + // var isExpanded = OpenedSpaces.Contains(space); + // + // // Console.WriteLine($"RecursingSpaceChildren::FetchData - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); + // + // // var renderSw = Stopwatch.StartNew(); + // var rf = new RenderFragment(builder => { + // builder.OpenElement(0, "div"); + // //space list entry render fragment + // // builder.AddContent(1, SpaceListEntry(space)); + // builder.OpenComponent(1); + // builder.AddAttribute(2, "Space", space); + // builder.AddAttribute(2, "OpenedSpaces", OpenedSpaces); + // builder.CloseComponent(); + // builder.CloseElement(); + // //space children render fragment + // if (isExpanded) { + // builder.OpenElement(2, "div"); + // builder.AddAttribute(3, "style", "padding-left: 10px;"); + // foreach (var child in children) { + // builder.AddContent(4, RecursingSpaceChildren(child, parents.Append(space).ToList(), depth + 1)); + // } + // + // builder.CloseElement(); + // } + // }); + // + // // Console.WriteLine($"RecursingSpaceChildren::Render - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {renderSw.Elapsed}"); + // if (totalSw.ElapsedMilliseconds > 20) + // Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); + // // Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); + // return rf; + // } // private RenderFragment SpaceListEntry(RoomInfo space) { // return builder => { -- cgit 1.4.1