mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-18 21:52:30 -04:00
feat(ffi): Create Room::new_latest_event + LatestEventValue.
This patch creates the `LatestEventValue` in `matrix_sdk_ffi` and exposes it via `Room::new_latest_event`.
This commit is contained in:
@@ -48,7 +48,7 @@ use crate::{
|
||||
runtime::get_runtime_handle,
|
||||
timeline::{
|
||||
configuration::{TimelineConfiguration, TimelineFilter},
|
||||
EventTimelineItem, ReceiptType, SendHandle, Timeline,
|
||||
EventTimelineItem, LatestEventValue, ReceiptType, SendHandle, Timeline,
|
||||
},
|
||||
utils::{u64_to_uint, AsyncRuntimeDropped},
|
||||
TaskHandle,
|
||||
@@ -305,7 +305,7 @@ impl Room {
|
||||
}
|
||||
|
||||
async fn new_latest_event(&self) -> LatestEventValue {
|
||||
self.inner.new_latest_event().await.map(Into::into)
|
||||
self.inner.new_latest_event().await.into()
|
||||
}
|
||||
|
||||
pub async fn latest_encryption_state(&self) -> Result<EncryptionState, ClientError> {
|
||||
|
||||
@@ -31,8 +31,8 @@ use matrix_sdk_common::{
|
||||
};
|
||||
use matrix_sdk_ui::timeline::{
|
||||
self, AttachmentConfig, AttachmentSource, EventItemOrigin,
|
||||
MediaUploadProgress as SdkMediaUploadProgress, Profile, TimelineDetails,
|
||||
TimelineUniqueId as SdkTimelineUniqueId,
|
||||
LatestEventValue as UiLatestEventValue, MediaUploadProgress as SdkMediaUploadProgress, Profile,
|
||||
TimelineDetails, TimelineUniqueId as SdkTimelineUniqueId,
|
||||
};
|
||||
use mime::Mime;
|
||||
use reply::{EmbeddedEventDetails, InReplyToDetails};
|
||||
@@ -1285,6 +1285,30 @@ impl LazyTimelineItemProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/// Mimic the [`UiLatestEventValue`] type.
|
||||
#[derive(Clone, uniffi::Enum)]
|
||||
pub enum LatestEventValue {
|
||||
None,
|
||||
Remote { timestamp: Timestamp, sender: String, content: TimelineItemContent },
|
||||
Local { timestamp: Timestamp, content: TimelineItemContent, is_sending: bool },
|
||||
}
|
||||
|
||||
impl From<UiLatestEventValue> for LatestEventValue {
|
||||
fn from(value: UiLatestEventValue) -> Self {
|
||||
match value {
|
||||
UiLatestEventValue::None => Self::None,
|
||||
UiLatestEventValue::Remote { timestamp, sender, content } => Self::Remote {
|
||||
timestamp: timestamp.into(),
|
||||
sender: sender.to_string(),
|
||||
content: content.into(),
|
||||
},
|
||||
UiLatestEventValue::Local { timestamp, content, is_sending } => {
|
||||
Self::Local { timestamp: timestamp.into(), content: content.into(), is_sending }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "unstable-msc4274")]
|
||||
mod galleries {
|
||||
use std::{panic, sync::Arc};
|
||||
|
||||
Reference in New Issue
Block a user