@page "/Rooms/{RoomId}/Timeline" @using MatrixRoomUtils.Web.Shared.TimelineComponents @using MatrixRoomUtils.Core.Responses

RoomManagerTimeline


Loaded @Events.Count events...

@foreach (var evt in Events) {
} @code { [Parameter] public string RoomId { get; set; } = "invalid!!!!!!"; private List Messages { get; } = new(); private List Events { get; } = new(); protected override async Task OnInitializedAsync() { RoomId = RoomId.Replace('~', '.'); Console.WriteLine("RoomId: " + RoomId); var hs = await MRUStorage.GetCurrentSessionOrNavigate(); if (hs is null) return; var room = await hs.GetRoom(RoomId); MessagesResponse? msgs = null; do { msgs = await room.GetMessagesAsync(limit: 250, from: msgs?.End, dir: "b"); Messages.Add(msgs); Console.WriteLine($"Got {msgs.Chunk.Count} messages"); msgs.Chunk.Reverse(); Events.InsertRange(0, msgs.Chunk); StateHasChanged(); } while (msgs.End is not null); await base.OnInitializedAsync(); } private StateEventResponse GetProfileEventBefore(StateEventResponse Event) => Events.TakeWhile(x => x != Event).Last(e => e.Type == "m.room.member" && e.StateKey == Event.Sender); private Type ComponentType(StateEventResponse Event) => Event.Type switch { "m.room.message" => typeof(TimelineMessageItem), "m.room.member" => typeof(TimelineMemberItem), _ => typeof(TimelineUnknownItem) }; private Dictionary ComponentParameters(Type ComponentType, StateEventResponse Event) => ComponentType switch { Type t when t == typeof(TimelineMessageItem) => new Dictionary { { "Event", Event }, { "Events", Events } }, Type t when t == typeof(TimelineMemberItem) => new Dictionary { { "Event", Event }, { "Events", Events } }, _ => new Dictionary { { "Event", Event }, { "Events", Events } } }; }