@@ -48,8 +48,8 @@ use ruma::{
4848 } ,
4949 receipt:: ReceiptThread ,
5050 room:: message:: {
51- FormattedBody as RumaFormattedBody , ForwardThread , LocationMessageEventContent ,
52- MessageType , RoomMessageEventContentWithoutRelation ,
51+ ForwardThread , LocationMessageEventContent , MessageType ,
52+ RoomMessageEventContentWithoutRelation ,
5353 } ,
5454 AnyMessageLikeEventContent ,
5555 } ,
@@ -81,6 +81,7 @@ use crate::{
8181mod content;
8282
8383pub use content:: MessageContent ;
84+ use matrix_sdk:: utils:: formatted_body_from;
8485
8586use crate :: error:: QueueWedgeError ;
8687
@@ -289,7 +290,8 @@ impl Timeline {
289290 progress_watcher : Option < Box < dyn ProgressWatcher > > ,
290291 use_send_queue : bool ,
291292 ) -> Arc < SendAttachmentJoinHandle > {
292- let formatted_caption = formatted_caption_from ( & caption, & formatted_caption) ;
293+ let formatted_caption =
294+ formatted_body_from ( caption. as_deref ( ) , formatted_caption. map ( Into :: into) ) ;
293295 SendAttachmentJoinHandle :: new ( RUNTIME . spawn ( async move {
294296 let base_image_info = BaseImageInfo :: try_from ( & image_info)
295297 . map_err ( |_| RoomError :: InvalidAttachmentData ) ?;
@@ -322,7 +324,8 @@ impl Timeline {
322324 progress_watcher : Option < Box < dyn ProgressWatcher > > ,
323325 use_send_queue : bool ,
324326 ) -> Arc < SendAttachmentJoinHandle > {
325- let formatted_caption = formatted_caption_from ( & caption, & formatted_caption) ;
327+ let formatted_caption =
328+ formatted_body_from ( caption. as_deref ( ) , formatted_caption. map ( Into :: into) ) ;
326329 SendAttachmentJoinHandle :: new ( RUNTIME . spawn ( async move {
327330 let base_video_info: BaseVideoInfo = BaseVideoInfo :: try_from ( & video_info)
328331 . map_err ( |_| RoomError :: InvalidAttachmentData ) ?;
@@ -353,7 +356,8 @@ impl Timeline {
353356 progress_watcher : Option < Box < dyn ProgressWatcher > > ,
354357 use_send_queue : bool ,
355358 ) -> Arc < SendAttachmentJoinHandle > {
356- let formatted_caption = formatted_caption_from ( & caption, & formatted_caption) ;
359+ let formatted_caption =
360+ formatted_body_from ( caption. as_deref ( ) , formatted_caption. map ( Into :: into) ) ;
357361 SendAttachmentJoinHandle :: new ( RUNTIME . spawn ( async move {
358362 let base_audio_info: BaseAudioInfo = BaseAudioInfo :: try_from ( & audio_info)
359363 . map_err ( |_| RoomError :: InvalidAttachmentData ) ?;
@@ -386,7 +390,8 @@ impl Timeline {
386390 progress_watcher : Option < Box < dyn ProgressWatcher > > ,
387391 use_send_queue : bool ,
388392 ) -> Arc < SendAttachmentJoinHandle > {
389- let formatted_caption = formatted_caption_from ( & caption, & formatted_caption) ;
393+ let formatted_caption =
394+ formatted_body_from ( caption. as_deref ( ) , formatted_caption. map ( Into :: into) ) ;
390395 SendAttachmentJoinHandle :: new ( RUNTIME . spawn ( async move {
391396 let base_audio_info: BaseAudioInfo = BaseAudioInfo :: try_from ( & audio_info)
392397 . map_err ( |_| RoomError :: InvalidAttachmentData ) ?;
@@ -714,24 +719,6 @@ impl Timeline {
714719 }
715720}
716721
717- /// Given a pair of optional `caption` and `formatted_caption` parameters,
718- /// return a formatted caption:
719- ///
720- /// - If a `formatted_caption` exists, return it.
721- /// - If it doesn't exist but there is a `caption`, parse it as markdown and
722- /// return the result.
723- /// - Return `None` if there are no `caption` or `formatted_caption` parameters.
724- fn formatted_caption_from (
725- caption : & Option < String > ,
726- formatted_caption : & Option < FormattedBody > ,
727- ) -> Option < RumaFormattedBody > {
728- match ( & caption, formatted_caption) {
729- ( None , None ) => None ,
730- ( Some ( body) , None ) => RumaFormattedBody :: markdown ( body) ,
731- ( _, Some ( formatted_body) ) => Some ( formatted_body. clone ( ) . into ( ) ) ,
732- }
733- }
734-
735722/// A handle to perform actions onto a local echo.
736723#[ derive( uniffi:: Object ) ]
737724pub struct SendHandle {
0 commit comments