refactor(common): TimelineEvent::event_id now returns an Option<&EventId>.

This patch updates `TimelineEvent::event_id` to return an
`Option<&EventId>` instead of an `Option<OwnedEventId>`. It avoids
cloning the event ID.
This commit is contained in:
Ivan Enderlin
2026-05-29 13:46:06 +02:00
parent d536dff709
commit b0fa52f17f

View File

@@ -15,7 +15,8 @@
use std::{collections::BTreeMap, fmt, ops::Not, sync::Arc};
use ruma::{
DeviceKeyAlgorithm, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedEventId, OwnedUserId,
DeviceKeyAlgorithm, EventId, MilliSecondsSinceUnixEpoch, OwnedDeviceId, OwnedEventId,
OwnedUserId,
events::{
AnySyncMessageLikeEvent, AnySyncTimelineEvent, AnyTimelineEvent, AnyToDeviceEvent,
MessageLikeEventType, room::encrypted::EncryptedEventScheme,
@@ -801,10 +802,10 @@ impl TimelineEvent {
self.push_actions = Some(push_actions);
}
/// Get the (cached) event ID of this [`TimelineEvent`] if the event has any
/// valid ID.
pub fn event_id(&self) -> Option<OwnedEventId> {
self.event_id.clone()
/// Get the (cached) event ID of this [`TimelineEvent`] if the event has
/// any valid ID.
pub fn event_id(&self) -> Option<&EventId> {
self.event_id.as_deref()
}
/// Get the sender of this [`TimelineEvent`] if the event has one.