mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-04-23 00:27:39 -04:00
refactor(event cache): add first_chunk_as_gap() in EventLinkedChunk too
This commit is contained in:
@@ -277,16 +277,8 @@ impl EventFocusedCacheInner {
|
||||
}
|
||||
|
||||
/// Return the first chunk as a gap, if it's one.
|
||||
///
|
||||
/// This stores the backward pagination token, in this case.
|
||||
fn first_chunk_as_gap(&self) -> Option<(ChunkIdentifier, Gap)> {
|
||||
self.chunk.chunks().next().and_then(|chunk| {
|
||||
if let ChunkContent::Gap(gap) = chunk.content() {
|
||||
Some((chunk.identifier(), gap.clone()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
self.chunk.first_chunk_as_gap()
|
||||
}
|
||||
|
||||
/// Return the last chunk as a gap, if it's one.
|
||||
|
||||
@@ -507,6 +507,17 @@ impl EventLinkedChunk {
|
||||
|
||||
replaced_some
|
||||
}
|
||||
|
||||
/// Return the first chunk as a gap, if it's one.
|
||||
pub fn first_chunk_as_gap(&self) -> Option<(ChunkIdentifier, Gap)> {
|
||||
self.chunks().next().and_then(|chunk| {
|
||||
if let ChunkContent::Gap(gap) = chunk.content() {
|
||||
Some((chunk.identifier(), gap.clone()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Methods related to lazy-loading.
|
||||
|
||||
Reference in New Issue
Block a user