@@ -542,6 +542,8 @@ impl RoomEventCacheInner {
542
542
room_events. push_events ( events. clone ( ) . into_iter ( ) ) ;
543
543
}
544
544
545
+ // Now that all events have been added, we can trigger the
546
+ // `pagination_token_notifier`.
545
547
if prev_batch. is_some ( ) {
546
548
self . pagination_token_notifier . notify_one ( ) ;
547
549
}
@@ -626,17 +628,21 @@ impl RoomEventCacheInner {
626
628
627
629
// There is a `token`/gap, let's replace it by new events!
628
630
if let Some ( gap_identifier) = gap_identifier {
629
- // Replace the gap by new events.
630
- room_events
631
- . replace_gap_at ( sync_events, gap_identifier)
632
- // SAFETY: we are sure that `gap_identifier` represents a valid `ChunkIdentifier`
633
- // for a gap.
634
- . unwrap ( ) ;
631
+ let new_position = {
632
+ // Replace the gap by new events.
633
+ let new_chunk = room_events
634
+ . replace_gap_at ( sync_events, gap_identifier)
635
+ // SAFETY: we are sure that `gap_identifier` represents a valid
636
+ // `ChunkIdentifier` for a gap.
637
+ . unwrap ( ) ;
638
+
639
+ new_chunk. first_position ( )
640
+ } ;
635
641
636
642
// And insert a new gap if there is any `prev_token`.
637
643
if let Some ( prev_token_gap) = prev_token {
638
644
room_events
639
- . insert_gap_at ( prev_token_gap, gap_identifier . into ( ) )
645
+ . insert_gap_at ( prev_token_gap, new_position )
640
646
// SAFETY: we are sure that `gap_identifier` represents a valid
641
647
// `ChunkIdentifier` for a gap.
642
648
. unwrap ( ) ;
0 commit comments