@page "/Rooms/{RoomId}/Timeline" @using MatrixUtils.Web.Shared.TimelineComponents @using LibMatrix @using LibMatrix.EventTypes.Spec @using LibMatrix.EventTypes.Spec.State

RoomManagerTimeline


Loaded @Events.Count events...

@foreach (var evt in Events) {
} @code { [Parameter] public string RoomId { get; set; } private List Events { get; } = new(); private List RawEvents { get; } = new(); private AuthenticatedHomeserverGeneric? Homeserver { get; set; } protected override async Task OnInitializedAsync() { Console.WriteLine("RoomId: " + RoomId); Homeserver = await RMUStorage.GetCurrentSessionOrNavigate(); if (Homeserver is null) return; var room = Homeserver.GetRoom(RoomId); MessagesResponse? msgs = null; do { msgs = await room.GetMessagesAsync(limit: 10000, from: msgs?.End, dir: "b"); Console.WriteLine($"Got {msgs.Chunk.Count} messages"); StateHasChanged(); msgs.Chunk.Reverse(); Events.InsertRange(0, msgs.Chunk.Select(x => new TimelineEventItem { Event = x, Type = ComponentType(x) })); RawEvents.InsertRange(0, msgs.Chunk); } while (msgs.End is not null); await base.OnInitializedAsync(); } // private StateEventResponse GetProfileEventBefore(StateEventResponse Event) => Events.TakeWhile(x => x != Event).Last(e => e.Type == RoomMemberEventContent.EventId && e.StateKey == Event.Sender); private Type ComponentType(StateEvent Event) => Event.Type switch { RoomCanonicalAliasEventContent.EventId => typeof(TimelineCanonicalAliasItem), RoomHistoryVisibilityEventContent.EventId => typeof(TimelineHistoryVisibilityItem), RoomTopicEventContent.EventId => typeof(TimelineRoomTopicItem), RoomMemberEventContent.EventId => typeof(TimelineMemberItem), RoomMessageEventContent.EventId => typeof(TimelineMessageItem), RoomCreateEventContent.EventId => typeof(TimelineRoomCreateItem), RoomNameEventContent.EventId => typeof(TimelineRoomNameItem), // RoomMessageReactionEventContent.EventId => typeof(ComponentBase), _ => typeof(TimelineUnknownItem) }; private class TimelineEventItem : ComponentBase { public StateEventResponse Event { get; set; } public Type Type { get; set; } } }