From de502f42c61990e07ed450f84612789e3b8a934d Mon Sep 17 00:00:00 2001 From: Doug Date: Wed, 31 Jul 2024 19:08:31 +0100 Subject: [PATCH] chore: Add docs & todo on EventTimelineItem::from_latest_event --- crates/matrix-sdk-ui/src/timeline/event_item/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs b/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs index 058bd22acfc..d23148928cd 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_item/mod.rs @@ -119,11 +119,20 @@ impl EventTimelineItem { /// If the supplied low-level `SyncTimelineEvent` is suitable for use as the /// `latest_event` in a message preview, wrap it as an `EventTimelineItem`. + /// + /// **Note:** Timeline items created via this constructor do **not** produce + /// the correct ShieldState when calling + /// [`get_shield`][EventTimelineItem::get_shield]. This is because they are + /// intended for display in the room list which a) is unlikely to show + /// shields and b) would incur a significant performance overhead. pub async fn from_latest_event( client: Client, room_id: &RoomId, latest_event: LatestEvent, ) -> Option { + // TODO: We shouldn't be returning an EventTimelineItem here because we're + // starting to diverge on what kind of data we need. The note above is a + // potential footgun which could one day turn into a security issue. use super::traits::RoomDataProvider; let SyncTimelineEvent { event: raw_sync_event, encryption_info, .. } =