mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-24 16:48:52 -04:00
feat(ui): expose timestamp and identifier on EmbeddedEvent
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
This commit is contained in:
committed by
Benjamin Bouvier
parent
3c873262c7
commit
12f94a3fd2
@@ -11,6 +11,8 @@ All notable changes to this project will be documented in this file.
|
||||
- Add `NotificationItem::room_topic` to the `NotificationItem` struct, which
|
||||
contains the topic of the room. This is useful for displaying the room topic
|
||||
in notifications. ([#5300](https://github.com/matrix-org/matrix-rust-sdk/pull/5300))
|
||||
- Add `EmbeddedEvent::timestamp` and `EmbeddedEvent::identifier` which are already
|
||||
available in regular timeline items. ([#5331](https://github.com/matrix-org/matrix-rust-sdk/pull/5331))
|
||||
|
||||
## [0.12.0] - 2025-06-10
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ use std::sync::Arc;
|
||||
|
||||
use imbl::Vector;
|
||||
use matrix_sdk::deserialized_responses::TimelineEvent;
|
||||
use ruma::{OwnedEventId, OwnedUserId};
|
||||
use ruma::{MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId};
|
||||
use tracing::{debug, instrument, warn};
|
||||
|
||||
use super::TimelineItemContent;
|
||||
@@ -25,7 +25,7 @@ use crate::timeline::{
|
||||
event_handler::TimelineAction,
|
||||
event_item::{EventTimelineItem, Profile, TimelineDetails},
|
||||
traits::RoomDataProvider,
|
||||
Error as TimelineError, TimelineItem,
|
||||
Error as TimelineError, TimelineEventItemId, TimelineItem,
|
||||
};
|
||||
|
||||
/// Details about an event being replied to.
|
||||
@@ -68,6 +68,13 @@ pub struct EmbeddedEvent {
|
||||
pub sender: OwnedUserId,
|
||||
/// The profile of the sender of the related embedded event.
|
||||
pub sender_profile: TimelineDetails<Profile>,
|
||||
/// The timestamp of the event.
|
||||
pub timestamp: MilliSecondsSinceUnixEpoch,
|
||||
/// The unique identifier of this event.
|
||||
///
|
||||
/// This is the transaction ID for a local echo that has not been sent and
|
||||
/// the event ID for a local echo that has been sent or a remote event.
|
||||
pub identifier: TimelineEventItemId,
|
||||
}
|
||||
|
||||
impl EmbeddedEvent {
|
||||
@@ -77,6 +84,8 @@ impl EmbeddedEvent {
|
||||
content: timeline_item.content.clone(),
|
||||
sender: timeline_item.sender.clone(),
|
||||
sender_profile: timeline_item.sender_profile.clone(),
|
||||
timestamp: timeline_item.timestamp,
|
||||
identifier: timeline_item.identifier(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +120,8 @@ impl EmbeddedEvent {
|
||||
let thread_summary = None;
|
||||
|
||||
let sender = event.sender().to_owned();
|
||||
let timestamp = event.origin_server_ts();
|
||||
let identifier = TimelineEventItemId::EventId(event.event_id().to_owned());
|
||||
let action = TimelineAction::from_event(
|
||||
event,
|
||||
&raw_event,
|
||||
@@ -132,6 +143,6 @@ impl EmbeddedEvent {
|
||||
room_data_provider.profile_from_user_id(&sender).await,
|
||||
);
|
||||
|
||||
Ok(Some(Self { content, sender, sender_profile }))
|
||||
Ok(Some(Self { content, sender, sender_profile, timestamp, identifier }))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use matrix_sdk_test::{
|
||||
};
|
||||
use matrix_sdk_ui::timeline::{
|
||||
Error as TimelineError, EventSendState, MsgLikeContent, MsgLikeKind, RoomExt, TimelineDetails,
|
||||
TimelineItemContent,
|
||||
TimelineEventItemId, TimelineItemContent,
|
||||
};
|
||||
use ruma::{
|
||||
event_id,
|
||||
@@ -31,7 +31,7 @@ use ruma::{
|
||||
sticker::{StickerEventContent, StickerMediaSource},
|
||||
Mentions,
|
||||
},
|
||||
owned_event_id, owned_mxc_uri, room_id,
|
||||
owned_event_id, owned_mxc_uri, room_id, MilliSecondsSinceUnixEpoch, UInt,
|
||||
};
|
||||
use serde_json::json;
|
||||
use stream_assert::{assert_next_matches, assert_pending};
|
||||
@@ -72,12 +72,15 @@ async fn test_in_reply_to_details() {
|
||||
|
||||
// Add an event and a reply to that event to the timeline
|
||||
let eid1 = event_id!("$event1");
|
||||
let timestamp = MilliSecondsSinceUnixEpoch(UInt::new(1984).unwrap());
|
||||
let f = EventFactory::new();
|
||||
server
|
||||
.sync_room(
|
||||
&client,
|
||||
JoinedRoomBuilder::new(room_id)
|
||||
.add_timeline_event(f.text_msg("hello").sender(*ALICE).event_id(eid1))
|
||||
.add_timeline_event(
|
||||
f.text_msg("hello").sender(*ALICE).event_id(eid1).server_ts(timestamp),
|
||||
)
|
||||
.add_timeline_event(f.text_msg("hello to you too").reply_to(eid1).sender(*BOB)),
|
||||
)
|
||||
.await;
|
||||
@@ -102,7 +105,9 @@ async fn test_in_reply_to_details() {
|
||||
);
|
||||
let in_reply_to = in_reply_to.clone().unwrap();
|
||||
assert_eq!(in_reply_to.event_id, eid1);
|
||||
assert_matches!(in_reply_to.event, TimelineDetails::Ready(_));
|
||||
assert_let!(TimelineDetails::Ready(embedded) = in_reply_to.event);
|
||||
assert_eq!(embedded.timestamp, timestamp);
|
||||
assert_eq!(embedded.identifier, TimelineEventItemId::EventId(eid1.to_owned()));
|
||||
|
||||
// Good old date divider.
|
||||
assert_let!(VectorDiff::PushFront { value: date_divider } = &timeline_updates[2]);
|
||||
|
||||
Reference in New Issue
Block a user