Skip to content

Commit 5f996f7

Browse files
committed
reafactor(ffi): Have ffi::Timeline::latest_event_id use ui::Timeline::latest_event_id, instead of ui::Timeline::latest_event
This is important because `latest_event` would also return local events, which won't have an event id.
1 parent 02491fc commit 5f996f7

File tree

2 files changed

+7
-2
lines changed
  • bindings/matrix-sdk-ffi/src/timeline
  • crates/matrix-sdk-ui/src/timeline

2 files changed

+7
-2
lines changed

bindings/matrix-sdk-ffi/src/timeline/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ impl Timeline {
367367

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

373373
/// Queues an event in the room's send queue so it's processed for

crates/matrix-sdk-ui/src/timeline/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl Timeline {
253253
Some(item.to_owned())
254254
}
255255

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

271+
/// Get the latest of the timeline's event ids.
272+
pub async fn latest_event_id(&self) -> Option<OwnedEventId> {
273+
self.controller.latest_event_id().await
274+
}
275+
271276
/// Get the current timeline items, along with a stream of updates of
272277
/// timeline items.
273278
///

0 commit comments

Comments
 (0)