@@ -35,8 +35,8 @@ use matrix_sdk_common::{
35
35
stream:: StreamExt ,
36
36
} ;
37
37
use matrix_sdk_ui:: timeline:: {
38
- self , AttachmentSource , EventItemOrigin , Profile , TimelineDetails ,
39
- TimelineUniqueId as SdkTimelineUniqueId ,
38
+ self , AttachmentSource , EventItemOrigin , EventSendProgress as SdkEventSendProgress , Profile ,
39
+ TimelineDetails , TimelineUniqueId as SdkTimelineUniqueId ,
40
40
} ;
41
41
use mime:: Mime ;
42
42
use reply:: { EmbeddedEventDetails , InReplyToDetails } ;
@@ -66,7 +66,7 @@ use uuid::Uuid;
66
66
use self :: content:: TimelineItemContent ;
67
67
pub use self :: msg_like:: MessageContent ;
68
68
use crate :: {
69
- client:: ProgressWatcher ,
69
+ client:: { AbstractProgress , ProgressWatcher } ,
70
70
error:: { ClientError , RoomError } ,
71
71
event:: EventOrTransactionId ,
72
72
helpers:: unwrap_or_clone_arc,
@@ -270,6 +270,31 @@ impl TryInto<Reply> for ReplyParameters {
270
270
}
271
271
}
272
272
273
+ /// This type represents the "send progress" of a local event timeline item.
274
+ #[ derive( Clone , Copy , uniffi:: Enum ) ]
275
+ pub enum EventSendProgress {
276
+ /// A media is being uploaded.
277
+ MediaUpload {
278
+ /// The index of the media within the transaction. A file and its
279
+ /// thumbnail share the same index.
280
+ index : u64 ,
281
+
282
+ /// The current combined upload progress for both the file and,
283
+ /// if it exists, its thumbnail.
284
+ progress : AbstractProgress ,
285
+ } ,
286
+ }
287
+
288
+ impl From < SdkEventSendProgress > for EventSendProgress {
289
+ fn from ( value : SdkEventSendProgress ) -> Self {
290
+ match value {
291
+ SdkEventSendProgress :: MediaUpload { index, progress } => {
292
+ Self :: MediaUpload { index, progress : progress. into ( ) }
293
+ }
294
+ }
295
+ }
296
+ }
297
+
273
298
#[ matrix_sdk_ffi_macros:: export]
274
299
impl Timeline {
275
300
pub async fn add_listener ( & self , listener : Box < dyn TimelineListener > ) -> Arc < TaskHandle > {
@@ -1018,7 +1043,10 @@ impl TimelineItem {
1018
1043
#[ derive( Clone , uniffi:: Enum ) ]
1019
1044
pub enum EventSendState {
1020
1045
/// The local event has not been sent yet.
1021
- NotSentYet ,
1046
+ NotSentYet {
1047
+ /// The progress of the sending operation, if any is available.
1048
+ progress : Option < EventSendProgress > ,
1049
+ } ,
1022
1050
1023
1051
/// The local event has been sent to the server, but unsuccessfully: The
1024
1052
/// sending has failed.
@@ -1043,7 +1071,9 @@ impl From<&matrix_sdk_ui::timeline::EventSendState> for EventSendState {
1043
1071
use matrix_sdk_ui:: timeline:: EventSendState :: * ;
1044
1072
1045
1073
match value {
1046
- NotSentYet => Self :: NotSentYet ,
1074
+ NotSentYet { progress } => {
1075
+ Self :: NotSentYet { progress : progress. clone ( ) . map ( |p| p. into ( ) ) }
1076
+ }
1047
1077
SendingFailed { error, is_recoverable } => {
1048
1078
let as_queue_wedge_error: matrix_sdk:: QueueWedgeError = ( & * * error) . into ( ) ;
1049
1079
Self :: SendingFailed {
0 commit comments