From f6cb8186c6e6e09bfd0debe34efa5edd3be6f898 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Thu, 12 Dec 2024 16:49:39 +0100 Subject: [PATCH] task(event cache): limit the display of event ids to 8 chars in the raw chunk debug string --- crates/matrix-sdk/src/event_cache/room/mod.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/matrix-sdk/src/event_cache/room/mod.rs b/crates/matrix-sdk/src/event_cache/room/mod.rs index 21e29594b..51072771d 100644 --- a/crates/matrix-sdk/src/event_cache/room/mod.rs +++ b/crates/matrix-sdk/src/event_cache/room/mod.rs @@ -816,9 +816,11 @@ mod private { let items = vec .into_iter() .map(|event| { - event - .event_id() - .map_or_else(|| "".to_owned(), |id| id.to_string()) + // Limit event ids to 8 chars *after* the $. + event.event_id().map_or_else( + || "".to_owned(), + |id| id.as_str().chars().take(1 + 8).collect(), + ) }) .collect::>() .join(", "); @@ -857,7 +859,9 @@ mod private { raws.push(RawChunk { content: ChunkContent::Items(vec![ - f.text_msg("hey").event_id(event_id!("$1")).into_sync(), + f.text_msg("hey") + .event_id(event_id!("$123456789101112131415617181920")) + .into_sync(), f.text_msg("you").event_id(event_id!("$2")).into_sync(), ]), identifier: CId::new(1), @@ -875,7 +879,7 @@ mod private { let output = raw_chunks_debug_string(raws); assert_eq!(output.len(), 2); assert_eq!(&output[0], "chunk #0 (prev=, next=1): gap['prev-token']"); - assert_eq!(&output[1], "chunk #1 (prev=0, next=): events[$1, $2]"); + assert_eq!(&output[1], "chunk #1 (prev=0, next=): events[$12345678, $2]"); } } }