Skip to content

Commit

Permalink
timeline: get rid of conversions from string to TimelineEventItemId
Browse files Browse the repository at this point in the history
I suppose these were useful at the FFI layer at some point, but they
aren't anymore, so they could be removed.

Changelog: Got rid of `From<String/&str>` for `TimelineEventItemId`.
  • Loading branch information
bnjbvr committed Oct 15, 2024
1 parent 4f51c40 commit f45e817
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions crates/matrix-sdk-ui/src/timeline/event_item/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,6 @@ impl From<OwnedTransactionId> for TimelineEventItemId {
}
}

// TODO remove those two
impl From<String> for TimelineEventItemId {
fn from(value: String) -> Self {
value.as_str().into()
}
}

impl From<&str> for TimelineEventItemId {
fn from(value: &str) -> Self {
if let Ok(event_id) = EventId::parse(value) {
TimelineEventItemId::EventId(event_id)
} else {
TimelineEventItemId::TransactionId(value.into())
}
}
}

/// An handle that usually allows to perform an action on a timeline event.
///
/// If the item represents a remote item, then the event id is usually
Expand Down Expand Up @@ -762,7 +745,7 @@ mod tests {
};

use super::{EventTimelineItem, Profile};
use crate::timeline::{TimelineDetails, TimelineEventItemId};
use crate::timeline::TimelineDetails;

#[async_test]
async fn test_latest_message_event_can_be_wrapped_as_a_timeline_item() {
Expand Down Expand Up @@ -987,20 +970,6 @@ mod tests {
);
}

#[test]
fn test_raw_event_id_into_timeline_event_item_id_gets_event_id() {
let raw_id = "$123:example.com";
let id: TimelineEventItemId = raw_id.into();
assert_matches!(id, TimelineEventItemId::EventId(_));
}

#[test]
fn test_raw_str_into_timeline_event_item_id_gets_transaction_id() {
let raw_id = "something something";
let id: TimelineEventItemId = raw_id.into();
assert_matches!(id, TimelineEventItemId::TransactionId(_));
}

fn member_event(
room_id: &RoomId,
user_id: &UserId,
Expand Down

0 comments on commit f45e817

Please sign in to comment.