@@ -48,8 +48,8 @@ use ruma::{
48
48
} ,
49
49
receipt:: ReceiptThread ,
50
50
room:: message:: {
51
- FormattedBody as RumaFormattedBody , ForwardThread , LocationMessageEventContent ,
52
- MessageType , RoomMessageEventContentWithoutRelation ,
51
+ ForwardThread , LocationMessageEventContent , MessageType ,
52
+ RoomMessageEventContentWithoutRelation ,
53
53
} ,
54
54
AnyMessageLikeEventContent ,
55
55
} ,
@@ -81,6 +81,7 @@ use crate::{
81
81
mod content;
82
82
83
83
pub use content:: MessageContent ;
84
+ use matrix_sdk:: utils:: formatted_body_from;
84
85
85
86
use crate :: error:: QueueWedgeError ;
86
87
@@ -289,7 +290,8 @@ impl Timeline {
289
290
progress_watcher : Option < Box < dyn ProgressWatcher > > ,
290
291
use_send_queue : bool ,
291
292
) -> 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) ) ;
293
295
SendAttachmentJoinHandle :: new ( RUNTIME . spawn ( async move {
294
296
let base_image_info = BaseImageInfo :: try_from ( & image_info)
295
297
. map_err ( |_| RoomError :: InvalidAttachmentData ) ?;
@@ -322,7 +324,8 @@ impl Timeline {
322
324
progress_watcher : Option < Box < dyn ProgressWatcher > > ,
323
325
use_send_queue : bool ,
324
326
) -> 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) ) ;
326
329
SendAttachmentJoinHandle :: new ( RUNTIME . spawn ( async move {
327
330
let base_video_info: BaseVideoInfo = BaseVideoInfo :: try_from ( & video_info)
328
331
. map_err ( |_| RoomError :: InvalidAttachmentData ) ?;
@@ -353,7 +356,8 @@ impl Timeline {
353
356
progress_watcher : Option < Box < dyn ProgressWatcher > > ,
354
357
use_send_queue : bool ,
355
358
) -> 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) ) ;
357
361
SendAttachmentJoinHandle :: new ( RUNTIME . spawn ( async move {
358
362
let base_audio_info: BaseAudioInfo = BaseAudioInfo :: try_from ( & audio_info)
359
363
. map_err ( |_| RoomError :: InvalidAttachmentData ) ?;
@@ -386,7 +390,8 @@ impl Timeline {
386
390
progress_watcher : Option < Box < dyn ProgressWatcher > > ,
387
391
use_send_queue : bool ,
388
392
) -> 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) ) ;
390
395
SendAttachmentJoinHandle :: new ( RUNTIME . spawn ( async move {
391
396
let base_audio_info: BaseAudioInfo = BaseAudioInfo :: try_from ( & audio_info)
392
397
. map_err ( |_| RoomError :: InvalidAttachmentData ) ?;
@@ -714,24 +719,6 @@ impl Timeline {
714
719
}
715
720
}
716
721
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
-
735
722
/// A handle to perform actions onto a local echo.
736
723
#[ derive( uniffi:: Object ) ]
737
724
pub struct SendHandle {
0 commit comments