From dd5cb220a0664682efd82c718efebe40e15c4337 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Tue, 3 Mar 2026 15:09:47 +0100 Subject: [PATCH] refactor(event cache): add `first_chunk_as_gap()` in `EventLinkedChunk` too --- .../matrix-sdk/src/event_cache/room/event_focused.rs | 10 +--------- crates/matrix-sdk/src/event_cache/room/events.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/matrix-sdk/src/event_cache/room/event_focused.rs b/crates/matrix-sdk/src/event_cache/room/event_focused.rs index 9c6d21336..e2d0beaa2 100644 --- a/crates/matrix-sdk/src/event_cache/room/event_focused.rs +++ b/crates/matrix-sdk/src/event_cache/room/event_focused.rs @@ -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. diff --git a/crates/matrix-sdk/src/event_cache/room/events.rs b/crates/matrix-sdk/src/event_cache/room/events.rs index d50dc7431..0cffeffdd 100644 --- a/crates/matrix-sdk/src/event_cache/room/events.rs +++ b/crates/matrix-sdk/src/event_cache/room/events.rs @@ -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.