mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-14 11:05:32 -04:00
ffi: get rid of get_timeline_event_content_by_event_id
This can be equivalently retrieved using: `get_timeline_event_by_event_id(event_id).content().as_message()?.content()` As per the commit date, this is used in one place in both EXA and EXI, so it seems fine to change the caller's call sites. And this avoids one explicit call site of `Timeline::item_by_event_id()`.
This commit is contained in:
@@ -16,7 +16,7 @@ use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use matrix_sdk::{crypto::types::events::UtdCause, room::power_levels::power_level_user_changes};
|
||||
use matrix_sdk_ui::timeline::{PollResult, TimelineDetails};
|
||||
use ruma::events::FullStateEventContent;
|
||||
use ruma::events::{room::message::RoomMessageEventContentWithoutRelation, FullStateEventContent};
|
||||
use tracing::warn;
|
||||
|
||||
use super::ProfileDetails;
|
||||
@@ -178,6 +178,10 @@ impl Message {
|
||||
pub fn is_edited(&self) -> bool {
|
||||
self.0.is_edited()
|
||||
}
|
||||
|
||||
pub fn content(&self) -> Arc<RoomMessageEventContentWithoutRelation> {
|
||||
Arc::new(RoomMessageEventContentWithoutRelation::new(self.0.msgtype().clone()))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(uniffi::Record)]
|
||||
|
||||
@@ -540,28 +540,6 @@ impl Timeline {
|
||||
Ok(Arc::new(EventTimelineItem(item)))
|
||||
}
|
||||
|
||||
pub async fn get_timeline_event_content_by_event_id(
|
||||
&self,
|
||||
event_id: String,
|
||||
) -> Result<Arc<RoomMessageEventContentWithoutRelation>, ClientError> {
|
||||
let event_id = EventId::parse(event_id)?;
|
||||
|
||||
let item = self
|
||||
.inner
|
||||
.item_by_event_id(&event_id)
|
||||
.await
|
||||
.context("Item with given event ID not found")?;
|
||||
|
||||
let msgtype = item
|
||||
.content()
|
||||
.as_message()
|
||||
.context("Item with given event ID is not a message")?
|
||||
.msgtype()
|
||||
.to_owned();
|
||||
|
||||
Ok(Arc::new(RoomMessageEventContentWithoutRelation::new(msgtype)))
|
||||
}
|
||||
|
||||
pub async fn latest_event(&self) -> Option<Arc<EventTimelineItem>> {
|
||||
let latest_event = self.inner.latest_event().await;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user