diff --git a/crates/matrix-sdk-ui/src/timeline/controller/state.rs b/crates/matrix-sdk-ui/src/timeline/controller/state.rs index 5a4a41908b2..d40e3c8e1bc 100644 --- a/crates/matrix-sdk-ui/src/timeline/controller/state.rs +++ b/crates/matrix-sdk-ui/src/timeline/controller/state.rs @@ -194,7 +194,8 @@ impl TimelineState

{ should_add_new_items, }; - let timeline_action = TimelineAction::from_content(content, in_reply_to, thread_root, None); + let timeline_action = + TimelineAction::from_content(content, None, in_reply_to, thread_root, None); TimelineEventHandler::new(&mut txn, ctx) .handle_event(&mut date_divider_adjuster, timeline_action, None) .await; diff --git a/crates/matrix-sdk-ui/src/timeline/event_handler.rs b/crates/matrix-sdk-ui/src/timeline/event_handler.rs index 7683906bbe5..21ba17b3e96 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_handler.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_handler.rs @@ -285,6 +285,7 @@ impl TimelineAction { // configured. We treat it the same as any other message-like event. Self::from_content( AnyMessageLikeEventContent::RoomEncrypted(content), + Some(raw_event), in_reply_to, thread_root, thread_summary, @@ -292,9 +293,13 @@ impl TimelineAction { } } - Some(content) => { - Self::from_content(content, in_reply_to, thread_root, thread_summary) - } + Some(content) => Self::from_content( + content, + Some(raw_event), + in_reply_to, + thread_root, + thread_summary, + ), None => Self::add_item(redacted_message_or_none(ev.event_type())?), }, @@ -369,6 +374,7 @@ impl TimelineAction { /// or an aggregation) is not supported for this event type. pub(super) fn from_content( content: AnyMessageLikeEventContent, + raw_event: Option<&Raw>, in_reply_to: Option, thread_root: Option, thread_summary: Option, @@ -465,7 +471,10 @@ impl TimelineAction { }, event => { - let other = OtherMessageLike { event_type: event.event_type() }; + let other = OtherMessageLike { + event_type: event.event_type(), + raw_event: raw_event.cloned(), + }; Self::AddItem { content: TimelineItemContent::MsgLike(MsgLikeContent { diff --git a/crates/matrix-sdk-ui/src/timeline/event_item/content/mod.rs b/crates/matrix-sdk-ui/src/timeline/event_item/content/mod.rs index 5eba63fd2bd..e3589a1374e 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_item/content/mod.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_item/content/mod.rs @@ -183,6 +183,7 @@ impl TimelineItemContent { None, None, None, + None, ) { TimelineAction::AddItem { content } => Some(content), _ => None, diff --git a/crates/matrix-sdk-ui/src/timeline/event_item/content/other.rs b/crates/matrix-sdk-ui/src/timeline/event_item/content/other.rs index 20ba3aaa012..9be05d6966d 100644 --- a/crates/matrix-sdk-ui/src/timeline/event_item/content/other.rs +++ b/crates/matrix-sdk-ui/src/timeline/event_item/content/other.rs @@ -15,21 +15,33 @@ //! Timeline item content for other message-like events created by the //! EventContent macro from ruma. -use ruma::events::MessageLikeEventType; +use ruma::{ + events::{AnyMessageLikeEventContent, AnySyncTimelineEvent, MessageLikeEventType}, + serde::Raw, +}; /// A custom event created by the EventContent macro from ruma. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone)] pub struct OtherMessageLike { pub(in crate::timeline) event_type: MessageLikeEventType, + pub(in crate::timeline) raw_event: Option>, } impl OtherMessageLike { - pub fn from_event_type(event_type: MessageLikeEventType) -> Self { - Self { event_type } + pub fn from_event_type_and_event( + event_type: MessageLikeEventType, + raw_event: Option>, + ) -> Self { + Self { event_type, raw_event } } /// Get the event_type of this message. pub fn event_type(&self) -> &MessageLikeEventType { &self.event_type } + + /// Get the raw event of this message, if available. + pub fn raw_event(&self) -> &Option> { + &self.raw_event + } } diff --git a/crates/matrix-sdk-ui/src/timeline/latest_event.rs b/crates/matrix-sdk-ui/src/timeline/latest_event.rs index 2cfd9f070d1..2a80ec77517 100644 --- a/crates/matrix-sdk-ui/src/timeline/latest_event.rs +++ b/crates/matrix-sdk-ui/src/timeline/latest_event.rs @@ -135,7 +135,13 @@ impl LatestEventValue { let profile = TimelineDetails::from_initial_value(Profile::load(room, &sender).await); - match TimelineAction::from_content(message_like_event_content, None, None, None) { + match TimelineAction::from_content( + message_like_event_content, + None, + None, + None, + None, + ) { TimelineAction::AddItem { content } => Self::Local { timestamp: *timestamp, sender,