Skip to content

Commit 337faf2

Browse files
committed
feat(event cache): include the lazy previous chunk in the debug string, if available
1 parent 9c2e705 commit 337faf2

File tree

2 files changed

+14
-1
lines changed
  • crates
    • matrix-sdk/src/event_cache/room
    • matrix-sdk-common/src/linked_chunk

2 files changed

+14
-1
lines changed

crates/matrix-sdk-common/src/linked_chunk/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,14 @@ impl<const CAPACITY: usize, Item, Gap> Chunk<CAPACITY, Item, Gap> {
12701270
self.next.is_none()
12711271
}
12721272

1273+
/// Return the link to the previous chunk, if it was loaded lazily.
1274+
///
1275+
/// Doc hidden because this is mostly for internal debugging purposes.
1276+
#[doc(hidden)]
1277+
pub fn lazy_previous(&self) -> Option<ChunkIdentifier> {
1278+
self.lazy_previous
1279+
}
1280+
12731281
/// Get the unique identifier of the chunk.
12741282
pub fn identifier(&self) -> ChunkIdentifier {
12751283
self.identifier

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,12 @@ impl RoomEvents {
341341

342342
for chunk in self.chunks() {
343343
let content = chunk_debug_string(chunk.content());
344-
let line = format!("chunk #{}: {content}", chunk.identifier().index());
344+
let lazy_previous = if let Some(cid) = chunk.lazy_previous() {
345+
format!(" (lazy previous = {})", cid.index())
346+
} else {
347+
"".to_owned()
348+
};
349+
let line = format!("chunk #{}{lazy_previous}: {content}", chunk.identifier().index());
345350

346351
result.push(line);
347352
}

0 commit comments

Comments
 (0)