about summary refs log tree commit diff
path: root/ModerationClient/Models/SpaceTreeNodes/SpaceNode.cs
blob: 781e974ed48d5e8bf3d1a4e342bc4d8e2ec064c1 (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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace ModerationClient.Models.SpaceTreeNodes;

public class SpaceNode : RoomNode {
    private bool _isExpanded = false;

    public SpaceNode(bool includeSelf = true) {
        if (includeSelf)
            ChildRooms = [this];

        ChildRooms.CollectionChanged += (_, _) => ChildRoomsByActivity = ChildRooms.OrderByDescending(x=>x.LastActivity).ToArray();
    }

    public ObservableCollection<SpaceNode> ChildSpaces { get; set; } = [];

    public ObservableCollection<RoomNode> ChildRooms {
        get;
        set => SetField(ref field, value);
    } = [];

    public RoomNode[] ChildRoomsByActivity {
        get;
        set => SetField(ref field, value);
    } = [];
}