mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-25 01:02:20 -04:00
sdk: Add EventTimelineItem::origin
This commit is contained in:
committed by
Jonas Platte
parent
f4929fd064
commit
f344aa7669
@@ -259,6 +259,20 @@ impl EventTimelineItem {
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the origin of the event, i.e. where it came from.
|
||||
///
|
||||
/// May return `None` in some edge cases that are subject to change.
|
||||
pub fn origin(&self) -> Option<EventItemOrigin> {
|
||||
match &self.kind {
|
||||
EventTimelineItemKind::Local(_) => Some(EventItemOrigin::Local),
|
||||
EventTimelineItemKind::Remote(remote_event) => match remote_event.origin {
|
||||
RemoteEventOrigin::Sync => Some(EventItemOrigin::Sync),
|
||||
RemoteEventOrigin::Pagination => Some(EventItemOrigin::Pagination),
|
||||
_ => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn set_content(&mut self, content: TimelineItemContent) {
|
||||
self.content = content;
|
||||
}
|
||||
@@ -357,3 +371,14 @@ impl<T> TimelineDetails<T> {
|
||||
matches!(self, Self::Ready(v) if v == value)
|
||||
}
|
||||
}
|
||||
|
||||
/// Where this event came.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub enum EventItemOrigin {
|
||||
/// The event was created locally.
|
||||
Local,
|
||||
/// The event came from a sync response.
|
||||
Sync,
|
||||
/// The event came from pagination.
|
||||
Pagination,
|
||||
}
|
||||
|
||||
@@ -70,9 +70,9 @@ pub(crate) use self::builder::TimelineBuilder;
|
||||
pub use self::sliding_sync_ext::SlidingSyncRoomExt;
|
||||
pub use self::{
|
||||
event_item::{
|
||||
AnyOtherFullStateEventContent, BundledReactions, EncryptedMessage, EventSendState,
|
||||
EventTimelineItem, InReplyToDetails, MemberProfileChange, MembershipChange, Message,
|
||||
OtherState, Profile, ReactionGroup, RepliedToEvent, RoomMembershipChange, Sticker,
|
||||
AnyOtherFullStateEventContent, BundledReactions, EncryptedMessage, EventItemOrigin,
|
||||
EventSendState, EventTimelineItem, InReplyToDetails, MemberProfileChange, MembershipChange,
|
||||
Message, OtherState, Profile, ReactionGroup, RepliedToEvent, RoomMembershipChange, Sticker,
|
||||
TimelineDetails, TimelineItemContent,
|
||||
},
|
||||
futures::SendAttachment,
|
||||
|
||||
Reference in New Issue
Block a user