Skip to content

Commit 6b86e1f

Browse files
committed
!fixup
1 parent 69ddc2a commit 6b86e1f

File tree

1 file changed

+13
-7
lines changed
  • crates/matrix-sdk/src/event_cache

1 file changed

+13
-7
lines changed

crates/matrix-sdk/src/event_cache/mod.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,8 @@ impl RoomEventCacheInner {
542542
room_events.push_events(events.clone().into_iter());
543543
}
544544

545+
// Now that all events have been added, we can trigger the
546+
// `pagination_token_notifier`.
545547
if prev_batch.is_some() {
546548
self.pagination_token_notifier.notify_one();
547549
}
@@ -626,17 +628,21 @@ impl RoomEventCacheInner {
626628

627629
// There is a `token`/gap, let's replace it by new events!
628630
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+
};
635641

636642
// And insert a new gap if there is any `prev_token`.
637643
if let Some(prev_token_gap) = prev_token {
638644
room_events
639-
.insert_gap_at(prev_token_gap, gap_identifier.into())
645+
.insert_gap_at(prev_token_gap, new_position)
640646
// SAFETY: we are sure that `gap_identifier` represents a valid
641647
// `ChunkIdentifier` for a gap.
642648
.unwrap();

0 commit comments

Comments
 (0)