From 0c01fec540c7325a4c558c7f4a8cc68eeb1bd587 Mon Sep 17 00:00:00 2001 From: Doug Date: Mon, 7 Oct 2024 11:24:20 +0100 Subject: [PATCH] ffi: Add caption to audio, file, image and video timeline items. --- bindings/matrix-sdk-ffi/src/ruma.rs | 32 ++++++++++++------- .../tests/integration/room_list_service.rs | 6 ++-- labs/multiverse/src/main.rs | 2 +- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/ruma.rs b/bindings/matrix-sdk-ffi/src/ruma.rs index 7072270d8e8..e842b06cbb9 100644 --- a/bindings/matrix-sdk-ffi/src/ruma.rs +++ b/bindings/matrix-sdk-ffi/src/ruma.rs @@ -277,7 +277,7 @@ impl TryFrom for RumaMessageType { RumaImageMessageEventContent::new(content.body, (*content.source).clone()) .info(content.info.map(Into::into).map(Box::new)); event_content.formatted = content.formatted.map(Into::into); - event_content.filename = content.filename; + event_content.filename = Some(content.filename); Self::Image(event_content) } MessageType::Audio { content } => { @@ -285,7 +285,7 @@ impl TryFrom for RumaMessageType { RumaAudioMessageEventContent::new(content.body, (*content.source).clone()) .info(content.info.map(Into::into).map(Box::new)); event_content.formatted = content.formatted.map(Into::into); - event_content.filename = content.filename; + event_content.filename = Some(content.filename); Self::Audio(event_content) } MessageType::Video { content } => { @@ -293,7 +293,7 @@ impl TryFrom for RumaMessageType { RumaVideoMessageEventContent::new(content.body, (*content.source).clone()) .info(content.info.map(Into::into).map(Box::new)); event_content.formatted = content.formatted.map(Into::into); - event_content.filename = content.filename; + event_content.filename = Some(content.filename); Self::Video(event_content) } MessageType::File { content } => { @@ -301,7 +301,7 @@ impl TryFrom for RumaMessageType { RumaFileMessageEventContent::new(content.body, (*content.source).clone()) .info(content.info.map(Into::into).map(Box::new)); event_content.formatted = content.formatted.map(Into::into); - event_content.filename = content.filename; + event_content.filename = Some(content.filename); Self::File(event_content) } MessageType::Notice { content } => { @@ -337,7 +337,8 @@ impl From for MessageType { content: ImageMessageContent { body: c.body.clone(), formatted: c.formatted.as_ref().map(Into::into), - filename: c.filename.clone(), + filename: c.filename().to_owned(), + caption: c.caption().map(ToString::to_string), source: Arc::new(c.source.clone()), info: c.info.as_deref().map(Into::into), }, @@ -346,7 +347,8 @@ impl From for MessageType { content: AudioMessageContent { body: c.body.clone(), formatted: c.formatted.as_ref().map(Into::into), - filename: c.filename.clone(), + filename: c.filename().to_owned(), + caption: c.caption().map(ToString::to_string), source: Arc::new(c.source.clone()), info: c.info.as_deref().map(Into::into), audio: c.audio.map(Into::into), @@ -357,7 +359,8 @@ impl From for MessageType { content: VideoMessageContent { body: c.body.clone(), formatted: c.formatted.as_ref().map(Into::into), - filename: c.filename.clone(), + filename: c.filename().to_owned(), + caption: c.caption().map(ToString::to_string), source: Arc::new(c.source.clone()), info: c.info.as_deref().map(Into::into), }, @@ -366,7 +369,8 @@ impl From for MessageType { content: FileMessageContent { body: c.body.clone(), formatted: c.formatted.as_ref().map(Into::into), - filename: c.filename.clone(), + filename: c.filename().to_owned(), + caption: c.caption().map(ToString::to_string), source: Arc::new(c.source.clone()), info: c.info.as_deref().map(Into::into), }, @@ -442,7 +446,8 @@ pub struct EmoteMessageContent { pub struct ImageMessageContent { pub body: String, pub formatted: Option, - pub filename: Option, + pub filename: String, + pub caption: Option, pub source: Arc, pub info: Option, } @@ -451,7 +456,8 @@ pub struct ImageMessageContent { pub struct AudioMessageContent { pub body: String, pub formatted: Option, - pub filename: Option, + pub filename: String, + pub caption: Option, pub source: Arc, pub info: Option, pub audio: Option, @@ -462,7 +468,8 @@ pub struct AudioMessageContent { pub struct VideoMessageContent { pub body: String, pub formatted: Option, - pub filename: Option, + pub filename: String, + pub caption: Option, pub source: Arc, pub info: Option, } @@ -471,7 +478,8 @@ pub struct VideoMessageContent { pub struct FileMessageContent { pub body: String, pub formatted: Option, - pub filename: Option, + pub filename: String, + pub caption: Option, pub source: Arc, pub info: Option, } diff --git a/crates/matrix-sdk-ui/tests/integration/room_list_service.rs b/crates/matrix-sdk-ui/tests/integration/room_list_service.rs index b37ec389f9c..e5bc16183a9 100644 --- a/crates/matrix-sdk-ui/tests/integration/room_list_service.rs +++ b/crates/matrix-sdk-ui/tests/integration/room_list_service.rs @@ -2141,7 +2141,7 @@ async fn test_room_subscription() -> Result<(), Error> { (StateEventType::RoomAvatar, "".to_owned()), (StateEventType::RoomCanonicalAlias, "".to_owned()), ], - timeline_limit: Some(uint!(30)), + timeline_limit: uint!(30), })), ); @@ -2184,7 +2184,7 @@ async fn test_room_subscription() -> Result<(), Error> { (StateEventType::RoomAvatar, "".to_owned()), (StateEventType::RoomCanonicalAlias, "".to_owned()), ], - timeline_limit: Some(uint!(30)), + timeline_limit: uint!(30), })), ); @@ -2227,7 +2227,7 @@ async fn test_room_subscription() -> Result<(), Error> { (StateEventType::RoomAvatar, "".to_owned()), (StateEventType::RoomCanonicalAlias, "".to_owned()), ], - timeline_limit: Some(uint!(30)), + timeline_limit: uint!(30), })), ); diff --git a/labs/multiverse/src/main.rs b/labs/multiverse/src/main.rs index 3829920569e..4a8f7938f7d 100644 --- a/labs/multiverse/src/main.rs +++ b/labs/multiverse/src/main.rs @@ -411,7 +411,7 @@ impl App { .and_then(|room_id| self.ui_rooms.lock().unwrap().get(&room_id).cloned()) { let mut sub = RoomSubscription::default(); - sub.timeline_limit = Some(uint!(30)); + sub.timeline_limit = uint!(30); self.sync_service.room_list_service().subscribe_to_rooms(&[room.room_id()], Some(sub)); self.current_room_subscription = Some(room);