@@ -31,7 +31,8 @@ use matrix_sdk_common::{
31
31
stream:: StreamExt ,
32
32
} ;
33
33
use matrix_sdk_ui:: timeline:: {
34
- self , AttachmentConfig , AttachmentSource , EventItemOrigin , Profile , TimelineDetails ,
34
+ self , AttachmentConfig , AttachmentSource , EventItemOrigin ,
35
+ EventSendProgress as SdkEventSendProgress , Profile , TimelineDetails ,
35
36
TimelineUniqueId as SdkTimelineUniqueId ,
36
37
} ;
37
38
use mime:: Mime ;
@@ -61,7 +62,7 @@ use uuid::Uuid;
61
62
use self :: content:: TimelineItemContent ;
62
63
pub use self :: msg_like:: MessageContent ;
63
64
use crate :: {
64
- client:: ProgressWatcher ,
65
+ client:: { AbstractProgress , ProgressWatcher } ,
65
66
error:: { ClientError , RoomError } ,
66
67
event:: EventOrTransactionId ,
67
68
helpers:: unwrap_or_clone_arc,
@@ -241,6 +242,32 @@ impl From<UploadSource> for AttachmentSource {
241
242
}
242
243
}
243
244
245
+ /// This type represents the "send progress" of a local event timeline item.
246
+ #[ derive( Clone , Copy , uniffi:: Enum ) ]
247
+ pub enum EventSendProgress {
248
+ /// A media is being uploaded.
249
+ MediaUpload {
250
+ /// The index of the media within the transaction. A file and its
251
+ /// thumbnail share the same index. Will always be 0 for non-gallery
252
+ /// media uploads.
253
+ index : u64 ,
254
+
255
+ /// The current combined upload progress for both the file and,
256
+ /// if it exists, its thumbnail.
257
+ progress : AbstractProgress ,
258
+ } ,
259
+ }
260
+
261
+ impl From < SdkEventSendProgress > for EventSendProgress {
262
+ fn from ( value : SdkEventSendProgress ) -> Self {
263
+ match value {
264
+ SdkEventSendProgress :: MediaUpload { index, progress } => {
265
+ Self :: MediaUpload { index, progress : progress. into ( ) }
266
+ }
267
+ }
268
+ }
269
+ }
270
+
244
271
#[ matrix_sdk_ffi_macros:: export]
245
272
impl Timeline {
246
273
pub async fn add_listener ( & self , listener : Box < dyn TimelineListener > ) -> Arc < TaskHandle > {
@@ -990,7 +1017,10 @@ impl TimelineItem {
990
1017
#[ derive( Clone , uniffi:: Enum ) ]
991
1018
pub enum EventSendState {
992
1019
/// The local event has not been sent yet.
993
- NotSentYet ,
1020
+ NotSentYet {
1021
+ /// The progress of the sending operation, if any is available.
1022
+ progress : Option < EventSendProgress > ,
1023
+ } ,
994
1024
995
1025
/// The local event has been sent to the server, but unsuccessfully: The
996
1026
/// sending has failed.
@@ -1015,7 +1045,9 @@ impl From<&matrix_sdk_ui::timeline::EventSendState> for EventSendState {
1015
1045
use matrix_sdk_ui:: timeline:: EventSendState :: * ;
1016
1046
1017
1047
match value {
1018
- NotSentYet => Self :: NotSentYet ,
1048
+ NotSentYet { progress } => {
1049
+ Self :: NotSentYet { progress : progress. clone ( ) . map ( |p| p. into ( ) ) }
1050
+ }
1019
1051
SendingFailed { error, is_recoverable } => {
1020
1052
let as_queue_wedge_error: matrix_sdk:: QueueWedgeError = ( & * * error) . into ( ) ;
1021
1053
Self :: SendingFailed {
0 commit comments