Skip to content

Commit

Permalink
feat(timeline): add a way to retrieve an EventTimelineItem by its u…
Browse files Browse the repository at this point in the history
…nique id
  • Loading branch information
bnjbvr committed Oct 10, 2024
1 parent 7873619 commit f0af335
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bindings/matrix-sdk-ffi/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,14 @@ impl Timeline {
Ok(())
}

/// Returns a timeline item, given its unique id.
pub async fn event_timeline_item_by_unique_id(
&self,
unique_id: &TimelineUniqueId,
) -> Option<EventTimelineItem> {
self.inner.event_timeline_item_by_unique_id(&unique_id.into()).await.map(Into::into)
}

pub async fn fetch_details_for_event(&self, event_id: String) -> Result<(), ClientError> {
let event_id = <&EventId>::try_from(event_id.as_str())?;
self.inner.fetch_details_for_event(event_id).await.context("Fetching event details")?;
Expand Down
9 changes: 9 additions & 0 deletions crates/matrix-sdk-ui/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,15 @@ impl Timeline {
Ok(true)
}

/// Returns a timeline item, given its unique id.
pub async fn event_timeline_item_by_unique_id(
&self,
unique_id: &TimelineUniqueId,
) -> Option<EventTimelineItem> {
let items = &self.controller.items().await;
rfind_event_by_uid(items, unique_id).map(|(_item_pos, item)| item.inner.clone())
}

/// Fetch unavailable details about the event with the given ID.
///
/// This method only works for IDs of remote [`EventTimelineItem`]s,
Expand Down

0 comments on commit f0af335

Please sign in to comment.