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.
This commit is contained in:
Krille 2023-12-18 13:45:15 +01:00
parent 5a22037cec
commit 39527c9033
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652
1 changed files with 9 additions and 8 deletions

View File

@ -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. // Fetch all users from database we have got here.
if (eventContextId == null) { if (eventContextId == null) {
for (final event in events) { 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; return timeline;
} }