Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/matrix-sdk-ui/src/timeline/controller/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ impl<P: RoomDataProvider> TimelineState<P> {
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;
Expand Down
17 changes: 13 additions & 4 deletions crates/matrix-sdk-ui/src/timeline/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,21 @@ 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,
)
}
}

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())?),
},
Expand Down Expand Up @@ -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<AnySyncTimelineEvent>>,
in_reply_to: Option<InReplyToDetails>,
thread_root: Option<OwnedEventId>,
thread_summary: Option<ThreadSummary>,
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl TimelineItemContent {
None,
None,
None,
None,
) {
TimelineAction::AddItem { content } => Some(content),
_ => None,
Expand Down
20 changes: 16 additions & 4 deletions crates/matrix-sdk-ui/src/timeline/event_item/content/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Raw<AnySyncTimelineEvent>>,
}

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<Raw<AnySyncTimelineEvent>>,
) -> 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<Raw<AnySyncTimelineEvent>> {
&self.raw_event
}
}
8 changes: 7 additions & 1 deletion crates/matrix-sdk-ui/src/timeline/latest_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading