Skip to content

Commit f0631bc

Browse files
committed
refactor(sdk): Move reached_start closer to where it is used.
This patch moves `reached_start` closer to where it is used: it is true if and only if the chunk content is `Items`, it is false for a `Gap`.
1 parent 914b712 commit f0631bc

File tree

1 file changed

+3
-5
lines changed
  • crates/matrix-sdk/src/event_cache/room

1 file changed

+3
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,6 @@ mod private {
920920

921921
let chunk_content = new_first_chunk.content.clone();
922922

923-
// We've reached the start on disk, if and only if, there was no chunk prior to
924-
// the one we just loaded.
925-
let reached_start = new_first_chunk.previous.is_none();
926-
927923
if let Err(err) = self.events.insert_new_chunk_as_first(new_first_chunk) {
928924
error!("error when inserting the previous chunk into its linked chunk: {err}");
929925

@@ -949,7 +945,9 @@ mod private {
949945
ChunkContent::Items(events) => LoadMoreEventsBackwardsOutcome::Events {
950946
events,
951947
timeline_event_diffs,
952-
reached_start,
948+
// We've reached the start on disk, if and only if, there was no chunk prior to
949+
// the one we just loaded.
950+
reached_start: self.events.chunks().next().unwrap().lazy_previous().is_none(),
953951
},
954952
})
955953
}

0 commit comments

Comments
 (0)