Skip to content

Commit 79c5edd

Browse files
mgoldenbergpoljar
authored andcommitted
refactor(ffi): add conversion from UploadSource to AttachmentSource
Signed-of-by: Michael Goldenberg <m@mgoldenberg.net>
1 parent bd6361e commit 79c5edd

File tree

1 file changed

+11
-7
lines changed
  • bindings/matrix-sdk-ffi/src/timeline

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,8 @@ impl Timeline {
130130
.reply(params.reply_params.map(|p| p.try_into()).transpose()?);
131131

132132
let handle = SendAttachmentJoinHandle::new(get_runtime_handle().spawn(async move {
133-
let source = match params.source {
134-
UploadSource::Data { data, filename } => {
135-
AttachmentSource::Data { bytes: data, filename }
136-
}
137-
UploadSource::File { filename } => AttachmentSource::File(filename.into()),
138-
};
139-
let mut request = self.inner.send_attachment(source, mime_type, attachment_config);
133+
let mut request =
134+
self.inner.send_attachment(params.source, mime_type, attachment_config);
140135

141136
if params.use_send_queue {
142137
request = request.use_send_queue();
@@ -239,6 +234,15 @@ pub enum UploadSource {
239234
},
240235
}
241236

237+
impl From<UploadSource> for AttachmentSource {
238+
fn from(value: UploadSource) -> Self {
239+
match value {
240+
UploadSource::File { filename } => Self::File(filename.into()),
241+
UploadSource::Data { data, filename } => Self::Data { bytes: data, filename },
242+
}
243+
}
244+
}
245+
242246
#[derive(uniffi::Record)]
243247
pub struct ReplyParameters {
244248
/// The ID of the event to reply to.

0 commit comments

Comments
 (0)