@using MatrixUtils.Abstractions
@using System.Security.Cryptography
@using ArcaneLibs.Extensions
RoomsIndex2MainTab
Uncategorised rooms
@foreach (var space in Data.Rooms.Where(x => x.RoomType == "m.space")) {
}
@code {
[CascadingParameter]
public Index2.RoomListViewData Data { get; set; } = null!;
protected override async Task OnInitializedAsync() {
Data.Rooms.CollectionChanged += (sender, args) => {
DebouncedStateHasChanged();
if (args.NewItems is { Count: > 0 })
foreach (var newItem in args.NewItems) {
(newItem as RoomInfo).PropertyChanged += (sender, args) => { DebouncedStateHasChanged(); };
}
};
await base.OnInitializedAsync();
}
//debounce StateHasChanged, we dont want to reredner on every key stroke
private CancellationTokenSource _debounceCts = new CancellationTokenSource();
private async Task DebouncedStateHasChanged() {
_debounceCts.Cancel();
_debounceCts = new CancellationTokenSource();
try {
await Task.Delay(100, _debounceCts.Token);
Console.WriteLine("DebouncedStateHasChanged - Calling StateHasChanged!");
StateHasChanged();
}
catch (TaskCanceledException) { }
}
}