From 5c5a9fb78c45f80330775286b65b5d78e3e99934 Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 31 Mar 2025 09:32:24 +0200 Subject: Cleanup and some error handling --- ModerationClient/Models/SpaceTreeNodes/SpaceNode.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'ModerationClient/Models/SpaceTreeNodes/SpaceNode.cs') diff --git a/ModerationClient/Models/SpaceTreeNodes/SpaceNode.cs b/ModerationClient/Models/SpaceTreeNodes/SpaceNode.cs index b8042ae..781e974 100644 --- a/ModerationClient/Models/SpaceTreeNodes/SpaceNode.cs +++ b/ModerationClient/Models/SpaceTreeNodes/SpaceNode.cs @@ -1,4 +1,7 @@ +using System; +using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; namespace ModerationClient.Models.SpaceTreeNodes; @@ -6,10 +9,21 @@ public class SpaceNode : RoomNode { private bool _isExpanded = false; public SpaceNode(bool includeSelf = true) { - if(includeSelf) + if (includeSelf) ChildRooms = [this]; + + ChildRooms.CollectionChanged += (_, _) => ChildRoomsByActivity = ChildRooms.OrderByDescending(x=>x.LastActivity).ToArray(); } public ObservableCollection ChildSpaces { get; set; } = []; - public ObservableCollection ChildRooms { get; set; } = []; + + public ObservableCollection ChildRooms { + get; + set => SetField(ref field, value); + } = []; + + public RoomNode[] ChildRoomsByActivity { + get; + set => SetField(ref field, value); + } = []; } \ No newline at end of file -- cgit 1.5.1