Skip to content

Commit

Permalink
refactor: Connect timeline to event updates earlier
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
krille-chan committed Dec 18, 2023
1 parent 0bb1e3b commit ad81f73
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/src/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit ad81f73

Please sign in to comment.