@page "/Tools/InviteCounter" @using ArcaneLibs.Extensions @using LibMatrix.RoomTypes @using System.Collections.ObjectModel @using LibMatrix @using System.Collections.Frozen @using LibMatrix.EventTypes.Spec.State @using MatrixUtils.Abstractions

User Trace



Room ID: Execute
Results @foreach (var (userId, events) in invites.OrderByDescending(x=>x.Value).ToList()) {

@userId: @events

}

@foreach (var line in log.Reverse()) {
@line
} @code { private ObservableCollection log { get; set; } = new(); private Dictionary invites { get; set; } = new(); private AuthenticatedHomeserverGeneric hs { get; set; } [Parameter, SupplyParameterFromQuery(Name = "room")] public string roomId { get; set; } protected override async Task OnInitializedAsync() { log.CollectionChanged += (sender, args) => StateHasChanged(); hs = await RMUStorage.GetCurrentSessionOrNavigate(); if (hs is null) return; StateHasChanged(); Console.WriteLine("Rerendered!"); await base.OnInitializedAsync(); } private async Task Execute() { var room = hs.GetRoom(roomId); var events = room.GetManyMessagesAsync(limit: int.MaxValue); await foreach (var resp in events) { var all = resp.State.Concat(resp.Chunk); foreach (var evt in all) { if(evt.Type != RoomMemberEventContent.EventId) continue; var content = evt.TypedContent as RoomMemberEventContent; if(content.Membership != "invite") continue; if(!invites.ContainsKey(evt.Sender)) invites[evt.Sender] = 0; invites[evt.Sender]++; } log.Add($"{resp.State.Count} state, {resp.Chunk.Count} timeline"); } StateHasChanged(); return ""; } }