From 03313562d21d5db9bf6a14ebbeab80e06c883d3a Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 24 Jan 2024 02:31:56 +0100 Subject: MRU->RMU, fixes, cleanup --- MatrixUtils.Web/Pages/Rooms/StateViewer.razor | 127 ++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 MatrixUtils.Web/Pages/Rooms/StateViewer.razor (limited to 'MatrixUtils.Web/Pages/Rooms/StateViewer.razor') diff --git a/MatrixUtils.Web/Pages/Rooms/StateViewer.razor b/MatrixUtils.Web/Pages/Rooms/StateViewer.razor new file mode 100644 index 0000000..fabc33c --- /dev/null +++ b/MatrixUtils.Web/Pages/Rooms/StateViewer.razor @@ -0,0 +1,127 @@ +@page "/Rooms/{RoomId}/State/View" +@using ArcaneLibs.Extensions +@using LibMatrix +@inject ILocalStorageService LocalStorage +@inject NavigationManager NavigationManager +

Room state viewer - Viewing @RoomId

+
+ +

@status

+ + Show member events + + + + + + + + + + @foreach (var stateEvent in FilteredEvents.Where(x => x.StateKey == "").OrderBy(x => x.OriginServerTs)) { + + + + + } + +
TypeContent
@stateEvent.Type +
@stateEvent.RawContent.ToJson()
+
+ +@foreach (var group in FilteredEvents.GroupBy(x => x.StateKey).OrderBy(x => x.Key).Where(x => x.Key != "")) { +
+ @group.Key + + + + + + + + + @foreach (var stateEvent in group.OrderBy(x => x.OriginServerTs)) { + + + + + } + +
TypeContent
@stateEvent.Type +
@stateEvent.RawContent.ToJson()
+
+
+} + + + +@code { + //get room list + // - sync withroom list filter + // Type = support.feline.msc3784 + //support.feline.policy.lists.msc.v1 + + [Parameter] + public string? RoomId { get; set; } + + public List FilteredEvents { get; set; } = new(); + public List Events { get; set; } = new(); + public string status = ""; + + protected override async Task OnInitializedAsync() { + await base.OnInitializedAsync(); + var hs = await RMUStorage.GetCurrentSessionOrNavigate(); + if (hs is null) return; + await LoadStatesAsync(); + Console.WriteLine("Policy list editor initialized!"); + } + + private DateTime _lastUpdate = DateTime.Now; + + private async Task LoadStatesAsync() { + var StateLoaded = 0; + var hs = await RMUStorage.GetCurrentSessionOrNavigate(); + if (hs is null) return; + var response = (hs.GetRoom(RoomId)).GetFullStateAsync(); + await foreach (var _ev in response) { + Events.Add(_ev); + if (string.IsNullOrEmpty(_ev.StateKey)) { + FilteredEvents.Add(_ev); + } + StateLoaded++; + + if (!((DateTime.Now - _lastUpdate).TotalMilliseconds > 100)) continue; + _lastUpdate = DateTime.Now; + status = $"Loaded {StateLoaded} state events"; + StateHasChanged(); + await Task.Delay(0); + } + + StateHasChanged(); + } + + private async Task RebuildFilteredData() { + status = "Rebuilding filtered data..."; + StateHasChanged(); + await Task.Delay(1); + var _FilteredEvents = Events; + if (!ShowMembershipEvents) + _FilteredEvents = _FilteredEvents.Where(x => x.Type != "m.room.member").ToList(); + + status = "Done, rerendering!"; + StateHasChanged(); + await Task.Delay(1); + FilteredEvents = _FilteredEvents; + StateHasChanged(); + } + + public bool ShowMembershipEvents { + get => _showMembershipEvents; + set { + _showMembershipEvents = value; + RebuildFilteredData(); + } + } + + private bool _showMembershipEvents; +} -- cgit 1.4.1