Skip to content

Commit 4da13e1

Browse files
committed
refactor!(ffi): use the send queue by default to upload medias
We do consider it stable now, after months of running it in production, so let's use it by default to simplify the `UploadParameters`.
1 parent 333d456 commit 4da13e1

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
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+
- The timeline will now always use the send queue to upload medias, so the
40+
`UploadParameters::use_send_queue` bool has been removed. Make sure to listen to the send queue's
41+
error updates, and to handle send queue restarts.
42+
([#5525](https://github.com/matrix-org/matrix-rust-sdk/pull/5525))
3943
- Support for the legacy media upload progress has been disabled. Media upload progress is
4044
available through the send queue, and can be enabled thanks to
4145
`Client::enable_send_queue_upload_progress()`.

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ impl Timeline {
101101
thumbnail: Option<Thumbnail>,
102102
) -> Result<Arc<SendAttachmentJoinHandle>, RoomError> {
103103
let mime_str = mime_type.as_ref().ok_or(RoomError::InvalidAttachmentMimeType)?;
104+
104105
let mime_type =
105106
mime_str.parse::<Mime>().map_err(|_| RoomError::InvalidAttachmentMimeType)?;
107+
106108
let in_reply_to_event_id = params
107109
.in_reply_to
108110
.map(EventId::parse)
@@ -125,15 +127,11 @@ impl Timeline {
125127
};
126128

127129
let handle = SendAttachmentJoinHandle::new(get_runtime_handle().spawn(async move {
128-
let mut request =
129-
self.inner.send_attachment(params.source, mime_type, attachment_config);
130-
131-
if params.use_send_queue {
132-
request = request.use_send_queue();
133-
}
134-
135-
request.await.map_err(|_| RoomError::FailedSendingAttachment)?;
136-
Ok(())
130+
self.inner
131+
.send_attachment(params.source, mime_type, attachment_config)
132+
.use_send_queue()
133+
.await
134+
.map_err(|_| RoomError::FailedSendingAttachment)
137135
}));
138136

139137
Ok(handle)
@@ -197,10 +195,6 @@ pub struct UploadParameters {
197195
mentions: Option<Mentions>,
198196
/// Optional Event ID to reply to.
199197
in_reply_to: Option<String>,
200-
/// Should the media be sent with the send queue, or synchronously?
201-
///
202-
/// Watching progress only works with the synchronous method, at the moment.
203-
use_send_queue: bool,
204198
}
205199

206200
/// A source for uploading a file

0 commit comments

Comments
 (0)