Skip to content

Commit 333d456

Browse files
committed
refactor!(ffi): remove legacy progress upload tracking
This can now be achieved by using the send queue's global progress support, i.e. `Client::enable_send_queue_upload_progress()`.
1 parent 01059ef commit 333d456

File tree

2 files changed

+9
-33
lines changed

2 files changed

+9
-33
lines changed

bindings/matrix-sdk-ffi/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ All notable changes to this project will be documented in this file.
3636

3737
### Breaking changes:
3838

39+
- Support for the legacy media upload progress has been disabled. Media upload progress is
40+
available through the send queue, and can be enabled thanks to
41+
`Client::enable_send_queue_upload_progress()`.
42+
([#5525](https://github.com/matrix-org/matrix-rust-sdk/pull/5525))
3943
- `TimelineDiff` is now exported as a true `uniffi::Enum` instead of the weird `uniffi::Object` hybrid. This matches
4044
both `RoomDirectorySearchEntryUpdate` and `RoomListEntriesUpdate` and can be used in the same way.
4145
([#5474](https://github.com/matrix-org/matrix-rust-sdk/pull/5474))

bindings/matrix-sdk-ffi/src/timeline/mod.rs

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ use uuid::Uuid;
6161
use self::content::TimelineItemContent;
6262
pub use self::msg_like::MessageContent;
6363
use crate::{
64-
client::ProgressWatcher,
6564
error::{ClientError, RoomError},
6665
event::EventOrTransactionId,
6766
ruma::{
@@ -99,7 +98,6 @@ impl Timeline {
9998
params: UploadParameters,
10099
attachment_info: AttachmentInfo,
101100
mime_type: Option<String>,
102-
progress_watcher: Option<Box<dyn ProgressWatcher>>,
103101
thumbnail: Option<Thumbnail>,
104102
) -> Result<Arc<SendAttachmentJoinHandle>, RoomError> {
105103
let mime_str = mime_type.as_ref().ok_or(RoomError::InvalidAttachmentMimeType)?;
@@ -134,15 +132,6 @@ impl Timeline {
134132
request = request.use_send_queue();
135133
}
136134

137-
if let Some(progress_watcher) = progress_watcher {
138-
let mut subscriber = request.subscribe_to_send_progress();
139-
get_runtime_handle().spawn(async move {
140-
while let Some(progress) = subscriber.next().await {
141-
progress_watcher.transmission_progress(progress.into());
142-
}
143-
});
144-
}
145-
146135
request.await.map_err(|_| RoomError::FailedSendingAttachment)?;
147136
Ok(())
148137
}));
@@ -399,78 +388,61 @@ impl Timeline {
399388
params: UploadParameters,
400389
thumbnail_path: Option<String>,
401390
image_info: ImageInfo,
402-
progress_watcher: Option<Box<dyn ProgressWatcher>>,
403391
) -> Result<Arc<SendAttachmentJoinHandle>, RoomError> {
404392
let attachment_info = AttachmentInfo::Image(
405393
BaseImageInfo::try_from(&image_info).map_err(|_| RoomError::InvalidAttachmentData)?,
406394
);
407395
let thumbnail = build_thumbnail_info(thumbnail_path, image_info.thumbnail_info)?;
408-
self.send_attachment(
409-
params,
410-
attachment_info,
411-
image_info.mimetype,
412-
progress_watcher,
413-
thumbnail,
414-
)
396+
self.send_attachment(params, attachment_info, image_info.mimetype, thumbnail)
415397
}
416398

417399
pub fn send_video(
418400
self: Arc<Self>,
419401
params: UploadParameters,
420402
thumbnail_path: Option<String>,
421403
video_info: VideoInfo,
422-
progress_watcher: Option<Box<dyn ProgressWatcher>>,
423404
) -> Result<Arc<SendAttachmentJoinHandle>, RoomError> {
424405
let attachment_info = AttachmentInfo::Video(
425406
BaseVideoInfo::try_from(&video_info).map_err(|_| RoomError::InvalidAttachmentData)?,
426407
);
427408
let thumbnail = build_thumbnail_info(thumbnail_path, video_info.thumbnail_info)?;
428-
self.send_attachment(
429-
params,
430-
attachment_info,
431-
video_info.mimetype,
432-
progress_watcher,
433-
thumbnail,
434-
)
409+
self.send_attachment(params, attachment_info, video_info.mimetype, thumbnail)
435410
}
436411

437412
pub fn send_audio(
438413
self: Arc<Self>,
439414
params: UploadParameters,
440415
audio_info: AudioInfo,
441-
progress_watcher: Option<Box<dyn ProgressWatcher>>,
442416
) -> Result<Arc<SendAttachmentJoinHandle>, RoomError> {
443417
let attachment_info = AttachmentInfo::Audio(
444418
BaseAudioInfo::try_from(&audio_info).map_err(|_| RoomError::InvalidAttachmentData)?,
445419
);
446-
self.send_attachment(params, attachment_info, audio_info.mimetype, progress_watcher, None)
420+
self.send_attachment(params, attachment_info, audio_info.mimetype, None)
447421
}
448422

449423
pub fn send_voice_message(
450424
self: Arc<Self>,
451425
params: UploadParameters,
452426
audio_info: AudioInfo,
453427
waveform: Vec<u16>,
454-
progress_watcher: Option<Box<dyn ProgressWatcher>>,
455428
) -> Result<Arc<SendAttachmentJoinHandle>, RoomError> {
456429
let attachment_info = AttachmentInfo::Voice {
457430
audio_info: BaseAudioInfo::try_from(&audio_info)
458431
.map_err(|_| RoomError::InvalidAttachmentData)?,
459432
waveform: Some(waveform),
460433
};
461-
self.send_attachment(params, attachment_info, audio_info.mimetype, progress_watcher, None)
434+
self.send_attachment(params, attachment_info, audio_info.mimetype, None)
462435
}
463436

464437
pub fn send_file(
465438
self: Arc<Self>,
466439
params: UploadParameters,
467440
file_info: FileInfo,
468-
progress_watcher: Option<Box<dyn ProgressWatcher>>,
469441
) -> Result<Arc<SendAttachmentJoinHandle>, RoomError> {
470442
let attachment_info = AttachmentInfo::File(
471443
BaseFileInfo::try_from(&file_info).map_err(|_| RoomError::InvalidAttachmentData)?,
472444
);
473-
self.send_attachment(params, attachment_info, file_info.mimetype, progress_watcher, None)
445+
self.send_attachment(params, attachment_info, file_info.mimetype, None)
474446
}
475447

476448
pub async fn create_poll(

0 commit comments

Comments
 (0)