Skip to content
2 changes: 1 addition & 1 deletion bindings/matrix-sdk-ffi/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ impl Timeline {

/// Returns the [`EventId`] of the latest event in the timeline.
pub async fn latest_event_id(&self) -> Option<String> {
self.inner.latest_event().await.and_then(|event| event.event_id().map(ToString::to_string))
self.inner.latest_event_id().await.as_deref().map(ToString::to_string)
}

/// Queues an event in the room's send queue so it's processed for
Expand Down
7 changes: 6 additions & 1 deletion crates/matrix-sdk-ui/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ impl Timeline {
Some(item.to_owned())
}

/// Get the latest of the timeline's event items.
/// Get the latest of the timeline's event items, both remote and local.
pub async fn latest_event(&self) -> Option<EventTimelineItem> {
if self.controller.is_live() {
self.controller.items().await.iter().rev().find_map(|item| {
Expand All @@ -268,6 +268,11 @@ impl Timeline {
}
}

/// Get the latest of the timeline's event ids.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to precise that, contrary to latest_event, this method only returns the ID of the last remote event (which is obvious for us because a local event doesn't have an event ID, only a transaction ID, but it's better to make it clear.

pub async fn latest_event_id(&self) -> Option<OwnedEventId> {
self.controller.latest_event_id().await
}

/// Get the current timeline items, along with a stream of updates of
/// timeline items.
///
Expand Down
Loading