about summary refs log tree commit diff
path: root/MatrixRoomUtils.Web/Pages/Rooms
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-07-17 03:14:38 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-07-17 03:14:38 +0200
commitd8b91f1c5e07a1aa30963977a145ff8ecde10a41 (patch)
treeaf12f3a2f81f75f5cd8e7e39c1b86d0f25374ffc /MatrixRoomUtils.Web/Pages/Rooms
parentHandle external logouts (diff)
downloadMatrixUtils-d8b91f1c5e07a1aa30963977a145ff8ecde10a41.tar.xz
Improve timeline
Diffstat (limited to 'MatrixRoomUtils.Web/Pages/Rooms')
-rw-r--r--MatrixRoomUtils.Web/Pages/Rooms/Index.razor8
-rw-r--r--MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor53
2 files changed, 57 insertions, 4 deletions
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
index a70ed9d..816299f 100644
--- a/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
+++ b/MatrixRoomUtils.Web/Pages/Rooms/Index.razor
@@ -52,7 +52,7 @@
         SyncResult? sync = null;
         string? nextBatch = null;
         while (sync is null or { Rooms.Join.Count: > 10}) {
-            sync = await hs.SyncHelper.Sync(since: nextBatch, filter: filter);
+            sync = await hs.SyncHelper.Sync(since: nextBatch, filter: filter, timeout: 0);
             nextBatch = sync?.NextBatch ?? nextBatch;
             if (sync is null) continue;
             Console.WriteLine($"Got sync, next batch: {nextBatch}!");
@@ -91,7 +91,7 @@
                 roomInfo.StateEvents.Add(new StateEventResponse() {
                     Type = "m.room.avatar",
                     TypedContent = new RoomAvatarEventData() {
-                        
+
                     }
                 });
             }
@@ -135,7 +135,7 @@
     }
 
     private bool RenderContents { get; set; } = false;
-    
+
     private string _status;
 
     public string Status {
@@ -146,4 +146,4 @@
         }
     }
 
-}
\ No newline at end of file
+}
diff --git a/MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor b/MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor
new file mode 100644
index 0000000..2234dd9
--- /dev/null
+++ b/MatrixRoomUtils.Web/Pages/Rooms/Timeline.razor
@@ -0,0 +1,53 @@
+@page "/Rooms/{RoomId}/Timeline"
+@using MatrixRoomUtils.Web.Shared.TimelineComponents
+@using MatrixRoomUtils.Core.Responses
+@using MatrixRoomUtils.Core.StateEventTypes.Spec
+<h3>RoomManagerTimeline</h3>
+<hr/>
+<p>Loaded @Events.Count events...</p>
+
+@foreach (var evt in Events) {
+    <div type="@evt.Type" key="@evt.StateKey" itemid="@evt.EventId">
+        <DynamicComponent Type="@ComponentType(evt)"
+                          Parameters="@(new Dictionary<string, object> { { "Event", evt }, { "Events", Events }, { "HomeServer", HomeServer!} })">
+        </DynamicComponent>
+    </div>
+}
+
+@code {
+
+    [Parameter]
+    public string RoomId { get; set; }
+
+    private List<MessagesResponse> Messages { get; } = new();
+    private List<StateEventResponse> Events { get; } = new();
+
+    private AuthenticatedHomeServer? HomeServer { get; set; }
+
+    protected override async Task OnInitializedAsync() {
+        Console.WriteLine("RoomId: " + RoomId);
+        HomeServer = await MRUStorage.GetCurrentSessionOrNavigate();
+        if (HomeServer is null) return;
+        var room = await HomeServer.GetRoom(RoomId);
+        MessagesResponse? msgs = null;
+        do {
+            msgs = await room.GetMessagesAsync(limit: 1000, from: msgs?.End, dir: "b");
+            Messages.Add(msgs);
+            Console.WriteLine($"Got {msgs.Chunk.Count} messages");
+            msgs.Chunk.Reverse();
+            Events.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 == "m.room.member" && e.StateKey == Event.Sender);
+
+    private Type ComponentType(StateEventResponse Event) => Event.TypedContent switch {
+        RoomMessageEventData => typeof(TimelineMessageItem),
+        RoomMemberEventData => typeof(TimelineMemberItem),
+        _ => typeof(TimelineUnknownItem)
+        };
+
+}