@using MatrixUtils.Web.Shared.RoomListComponents;
@using System.Collections.ObjectModel
@using LibMatrix.Responses
@using MatrixUtils.Abstractions
@if (!StillFetching) {
Fetching room details... @RoomsWithTypes.Sum(x => x.Value.Count) out of @Rooms.Count done!
@foreach (var category in RoomsWithTypes.OrderBy(x => x.Value.Count)) {
@category.Key (@category.Value.Count)
}
}
else {
@foreach (var category in RoomsWithTypes.OrderBy(x => x.Value.Count)) {
}
}
@code {
private ObservableCollection _rooms;
[Parameter]
public ObservableCollection Rooms {
get => _rooms;
set {
if(_rooms != value)
value.CollectionChanged += (_, args) => {
foreach (RoomInfo item in args.NewItems??(object[])[]) {
item.PropertyChanged += (_, args2) => {
if (args2.PropertyName == nameof(item.CreationEventContent))
StateHasChanged();
};
}
};
_rooms = value;
}
}
[Parameter]
public UserProfileResponse? GlobalProfile { get; set; }
[Parameter]
public bool StillFetching { get; set; } = true;
[Parameter]
public EventCallback StillFetchingChanged { get; set; }
private Dictionary> RoomsWithTypes => Rooms is null ? new() : Rooms.GroupBy(x => GetRoomTypeName(x.RoomType)).ToDictionary(x => x.Key, x => x.ToList());
private string GetRoomTypeName(string? roomType) => roomType switch {
null => "Room",
"m.space" => "Space",
"msc3588.stories.stories-room" => "Story room",
"support.feline.policy.lists.msc.v1" => "MSC3784 policy list (v1)",
// custom names
"gay.rory.moderation_bot.policy_room" => "Rory&::ModerationBot policy room",
"gay.rory.moderation_bot.log_room" => "Rory&::ModerationBot log room",
"gay.rory.moderation_bot.control_room" => "Rory&::ModerationBot control room",
// fallback
"gay.rory.rmu.fallback.policy_list" => "\"Legacy\" policy list (unmarked room)",
_ => roomType
};
}