Skip to content

Commit

Permalink
common: make TimelineEvent::into_event return a `Raw<AnySyncTimelin…
Browse files Browse the repository at this point in the history
…eEvent>`
  • Loading branch information
richvdh committed Oct 4, 2024
1 parent 3d95448 commit c24036f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
5 changes: 3 additions & 2 deletions crates/matrix-sdk-common/src/deserialized_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,9 @@ impl TimelineEvent {

/// Takes ownership of this `TimelineEvent`, returning the (potentially
/// decrypted) Matrix event within.
pub fn into_event(self) -> Raw<AnyTimelineEvent> {
self.inner_event
pub fn into_event(self) -> Raw<AnySyncTimelineEvent> {
// TODO: make `inner_event` an AnySyncTimelineEvent instead.
self.inner_event.cast()
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk-ui/src/notification_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ impl NotificationClient {
self.retry_decryption(&room, timeline_event).await?
{
let push_actions = timeline_event.push_actions.take();
raw_event = RawNotificationEvent::Timeline(timeline_event.into_event().cast());
raw_event = RawNotificationEvent::Timeline(timeline_event.into_event());
push_actions
} else {
room.event_push_actions(timeline_event).await?
Expand Down Expand Up @@ -566,7 +566,7 @@ impl NotificationClient {
Ok(Some(
NotificationItem::new(
&room,
RawNotificationEvent::Timeline(timeline_event.into_event().cast()),
RawNotificationEvent::Timeline(timeline_event.into_event()),
push_actions.as_deref(),
state_events,
)
Expand Down
6 changes: 1 addition & 5 deletions crates/matrix-sdk-ui/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,7 @@ impl Timeline {
UnsupportedReplyItem::MissingEvent
})?;

// We need to get the content and we can do that by casting the event as a
// `AnySyncTimelineEvent` which is the same as a `AnyTimelineEvent`, but without
// the `room_id` field. The cast is valid because we are just losing
// track of such field.
let raw_sync_event: Raw<AnySyncTimelineEvent> = event.into_event().cast();
let raw_sync_event = event.into_event();
let sync_event = raw_sync_event.deserialize().map_err(|error| {
error!("Failed to deserialize event with ID {event_id} with error: {error}");
UnsupportedReplyItem::FailedToDeserializeEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ impl TestHelper {

if add_to_timeline {
joined_room_builder =
joined_room_builder.add_timeline_event(timeline_event.into_event().cast());
joined_room_builder.add_timeline_event(timeline_event.into_event());
}
}

Expand Down

0 comments on commit c24036f

Please sign in to comment.