From 39527c90330d4b6b40681a70008dffe661bb07f6 Mon Sep 17 00:00:00 2001 From: Krille Date: Mon, 18 Dec 2023 13:45:15 +0100 Subject: [PATCH] refactor: Connect timeline to event updates earlier This creates the timeline object earlier in the Room.getTimeline() method. This results to that the Timeline object already starts to listen on the event stream while the getTimeline() method requests users from the database and tries to decrypt room events. I assume that this causes the problem that on timeline creation new events get lost because they come in, while getTimeline() is not yet completed but the onEvent stream is not yet connected at the same time. --- lib/src/room.dart | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index 11db7672..92f5a4e2 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -1488,6 +1488,15 @@ class Room { } } + final timeline = Timeline( + room: this, + chunk: chunk, + onChange: onChange, + onRemove: onRemove, + onInsert: onInsert, + onNewEvent: onNewEvent, + onUpdate: onUpdate); + // Fetch all users from database we have got here. if (eventContextId == null) { for (final event in events) { @@ -1528,14 +1537,6 @@ class Room { } } - final timeline = Timeline( - room: this, - chunk: chunk, - onChange: onChange, - onRemove: onRemove, - onInsert: onInsert, - onNewEvent: onNewEvent, - onUpdate: onUpdate); return timeline; }