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);
    } = [];
}