From a055aa3e576ed54c962a4e752dd0805cf1c8809b Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 18 Feb 2025 16:54:33 +0100 Subject: [PATCH] chore(sdk): Fix comments and rename variables. --- crates/matrix-sdk-common/src/linked_chunk/builder.rs | 4 ++-- crates/matrix-sdk/src/event_cache/pagination.rs | 10 +++++----- crates/matrix-sdk/src/event_cache/room/mod.rs | 4 ---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/crates/matrix-sdk-common/src/linked_chunk/builder.rs b/crates/matrix-sdk-common/src/linked_chunk/builder.rs index 38ea2801a..f9e7a52de 100644 --- a/crates/matrix-sdk-common/src/linked_chunk/builder.rs +++ b/crates/matrix-sdk-common/src/linked_chunk/builder.rs @@ -61,7 +61,7 @@ impl LinkedChunkBuilder { // Create the `LinkedChunk` from a single chunk. { - // This is the only chunk. Pretend it has no previous chunk if any. + // Take the `previous` chunk and consider it becomes the `lazy_previous`. let lazy_previous = chunk.previous.take(); // Transform the `RawChunk` into a `Chunk`. @@ -184,7 +184,7 @@ impl LinkedChunkBuilder { } } - // Emit the updates.. + // Emit the updates. if let Some(updates) = linked_chunk.updates.as_mut() { let first_chunk = linked_chunk.links.first_chunk(); diff --git a/crates/matrix-sdk/src/event_cache/pagination.rs b/crates/matrix-sdk/src/event_cache/pagination.rs index 176fd5129..9c0f0bf93 100644 --- a/crates/matrix-sdk/src/event_cache/pagination.rs +++ b/crates/matrix-sdk/src/event_cache/pagination.rs @@ -238,7 +238,7 @@ impl RoomPagination { // Reverse the order of the events as `/messages` has been called with `dir=b` // (backwards). The `RoomEvents` API expects the first event to be the oldest. // Let's re-order them for this block. - let events = events + let reversed_events = events .iter() .rev() .cloned() @@ -258,7 +258,7 @@ impl RoomPagination { trace!("replacing previous gap with the back-paginated events"); // Replace the gap with the events we just deduplicated. - room_events.replace_gap_at(events.clone(), gap_id) + room_events.replace_gap_at(reversed_events.clone(), gap_id) .expect("gap_identifier is a valid chunk id we read previously") } } else if let Some(pos) = first_event_pos { @@ -267,7 +267,7 @@ impl RoomPagination { trace!("inserted events before the first known event"); room_events - .insert_events_at(events.clone(), pos) + .insert_events_at(reversed_events.clone(), pos) .expect("pos is a valid position we just read above"); Some(pos) @@ -275,7 +275,7 @@ impl RoomPagination { // No prior gap, and no prior events: push the events. trace!("pushing events received from back-pagination"); - room_events.push_events(events.clone()); + room_events.push_events(reversed_events.clone()); // A new gap may be inserted before the new events, if there are any. room_events.events().next().map(|(item_pos, _)| item_pos) @@ -299,7 +299,7 @@ impl RoomPagination { debug!("not storing previous batch token, because we deduplicated all new back-paginated events"); } - room_events.on_new_events(&self.inner.room_version, events.iter()); + room_events.on_new_events(&self.inner.room_version, reversed_events.iter()); }) .await?; diff --git a/crates/matrix-sdk/src/event_cache/room/mod.rs b/crates/matrix-sdk/src/event_cache/room/mod.rs index aff5eb27f..f330ddc1b 100644 --- a/crates/matrix-sdk/src/event_cache/room/mod.rs +++ b/crates/matrix-sdk/src/event_cache/room/mod.rs @@ -657,10 +657,6 @@ mod private { } /// Load more events backwards if the last chunk is **not** a gap. - /// - /// Return `Ok(Some((events, reached_start), _))` if events have been - /// inserted, `Ok(None)` if a gap has been inserted or if the - /// store is disabled. #[must_use = "Updates as `VectorDiff` must probably be propagated via `RoomEventCacheUpdate`"] pub(in super::super) async fn load_more_events_backwards( &mut self,