Skip to content

Commit

Permalink
refactor(timeline): get rid of local_item_by_transaction_id
Browse files Browse the repository at this point in the history
There's no need for this API anymore.

Changelog: `Timeline::get_event_timeline_item_by_transaction_id` has
been removed. There's no API that makes use of an `EventTimelineItem`
now, those APIs are using a `TimelineEventItemId` instead.
  • Loading branch information
bnjbvr committed Oct 17, 2024
1 parent 821fa8f commit 4611ad1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 46 deletions.
20 changes: 0 additions & 20 deletions bindings/matrix-sdk-ffi/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,26 +595,6 @@ impl Timeline {
Ok(item.into())
}

/// Get the current timeline item for the given transaction ID, if any.
///
/// This will always return a local echo, if found.
///
/// It's preferable to store the timeline items in the model for your UI, if
/// possible, instead of just storing IDs and coming back to the timeline
/// object to look up items.
pub async fn get_event_timeline_item_by_transaction_id(
&self,
transaction_id: String,
) -> Result<EventTimelineItem, ClientError> {
let transaction_id: OwnedTransactionId = transaction_id.into();
let item = self
.inner
.local_item_by_transaction_id(&transaction_id)
.await
.context("Item with given transaction ID not found")?;
Ok(item.into())
}

/// Redacts an event from the timeline.
///
/// Only works for events that exist as timeline items.
Expand Down
28 changes: 2 additions & 26 deletions crates/matrix-sdk-ui/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ use ruma::{
SyncMessageLikeEvent,
},
serde::Raw,
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId, RoomVersionId, TransactionId,
UserId,
EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId, RoomVersionId, UserId,
};
use thiserror::Error;
use tracing::{error, instrument, trace, warn};
Expand Down Expand Up @@ -95,11 +94,7 @@ pub use self::{
traits::RoomExt,
virtual_item::VirtualTimelineItem,
};
use self::{
controller::TimelineController,
futures::SendAttachment,
util::{rfind_event_by_id, rfind_event_item},
};
use self::{controller::TimelineController, futures::SendAttachment, util::rfind_event_by_id};

/// Information needed to reply to an event.
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -253,25 +248,6 @@ impl Timeline {
Some(item.to_owned())
}

/// Get the current local echo timeline item for the given transaction ID,
/// if any.
///
/// This will always return a local echo, if found.
///
/// It's preferable to store the timeline items in the model for your UI, if
/// possible, instead of just storing IDs and coming back to the timeline
/// object to look up items.
pub async fn local_item_by_transaction_id(
&self,
target: &TransactionId,
) -> Option<EventTimelineItem> {
let items = self.controller.items().await;
let (_, item) = rfind_event_item(&items, |item| {
item.as_local().map_or(false, |local| local.transaction_id == target)
})?;
Some(item.to_owned())
}

/// Get the latest of the timeline's event items.
pub async fn latest_event(&self) -> Option<EventTimelineItem> {
if self.controller.is_live().await {
Expand Down

0 comments on commit 4611ad1

Please sign in to comment.