Skip to content

Commit

Permalink
more formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
surakin committed Mar 17, 2024
1 parent 74ca821 commit 24931fe
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 75 deletions.
58 changes: 31 additions & 27 deletions bindings/matrix-sdk-ffi/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use crate::{
error::{ClientError, RoomError},
helpers::unwrap_or_clone_arc,
ruma::{
AssetType, AudioInfo, FileInfo, FormattedBody, ImageInfo, PollKind, ThumbnailInfo,
AssetType, AudioInfo, FileInfo, FormattedBody, ImageInfo, PollKind, ThumbnailInfo,
VideoInfo,
},
task_handle::TaskHandle,
Expand Down Expand Up @@ -119,7 +119,7 @@ impl Timeline {
Some(p) => Some(RumaFormattedBody::from(p)),
None => None,
};
let request =
let request =
self.inner.send_attachment(url, mime_type, attachment_config, caption, formatted);
if let Some(progress_watcher) = progress_watcher {
let mut subscriber = request.subscribe_to_send_progress();
Expand Down Expand Up @@ -252,13 +252,14 @@ impl Timeline {
};

self.send_attachment(
url,
mime_type,
attachment_config,
url,
mime_type,
attachment_config,
caption,
formatted,
progress_watcher
).await
formatted,
progress_watcher,
)
.await
}))
}

Expand Down Expand Up @@ -292,13 +293,14 @@ impl Timeline {
};

self.send_attachment(
url,
mime_type,
attachment_config,
caption,
url,
mime_type,
attachment_config,
caption,
formatted,
progress_watcher
).await
progress_watcher,
)
.await
}))
}

Expand All @@ -323,13 +325,14 @@ impl Timeline {
let attachment_config = AttachmentConfig::new().info(attachment_info);

self.send_attachment(
url,
mime_type,
attachment_config,
caption,
formatted,
progress_watcher
).await
url,
mime_type,
attachment_config,
caption,
formatted,
progress_watcher,
)
.await
}))
}

Expand Down Expand Up @@ -357,12 +360,13 @@ impl Timeline {

self.send_attachment(
url,
mime_type,
attachment_config,
caption,
formatted,
progress_watcher
).await
mime_type,
attachment_config,
caption,
formatted,
progress_watcher,
)
.await
}))
}

Expand Down
16 changes: 8 additions & 8 deletions crates/matrix-sdk-ui/src/timeline/futures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ impl<'a> IntoFuture for SendAttachment<'a> {

fn into_future(self) -> Self::IntoFuture {
let Self {
timeline,
url,
mime_type,
config,
caption,
formatted,
tracing_span,
send_progress
timeline,
url,
mime_type,
config,
caption,
formatted,
tracing_span,
send_progress,
} = self;
let fut = async move {
let urlbody = Path::new(&url)
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk-ui/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ impl Timeline {
///
/// * `config` - An attachment configuration object containing details about
/// the attachment
///
///
/// * `caption` - An optional caption of this attachment
///
/// * `formatted` - An optional formatted caption of this attachment
Expand Down
5 changes: 3 additions & 2 deletions crates/matrix-sdk/src/encryption/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ use ruma::{
assign,
events::room::{
message::{
AudioMessageEventContent, FileInfo, FileMessageEventContent, FormattedBody,
AudioMessageEventContent, FileInfo, FileMessageEventContent, FormattedBody,
ImageMessageEventContent, MessageType, VideoInfo, VideoMessageEventContent,
},
ImageInfo, MediaSource, ThumbnailInfo,
Expand Down Expand Up @@ -329,7 +329,7 @@ impl Client {
Some(caption) => (caption, Some(url)),
None => (url, None),
};

Ok(match content_type.type_() {
mime::IMAGE => {
let info = assign!(info.map(ImageInfo::from).unwrap_or_default(), {
Expand Down Expand Up @@ -1447,6 +1447,7 @@ impl Encryption {
#[cfg(all(test, not(target_arch = "wasm32")))]
mod tests {
use std::time::Duration;

use matrix_sdk_base::SessionMeta;
use matrix_sdk_test::{
async_test, test_json, GlobalAccountDataTestEvent, JoinedRoomBuilder, StateTestEvent,
Expand Down
6 changes: 3 additions & 3 deletions crates/matrix-sdk/src/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ use ruma::{
assign,
events::room::{
message::{
self, AudioInfo, AudioMessageEventContent, FileInfo, FileMessageEventContent,
FormattedBody, ImageMessageEventContent, MessageType, UnstableAudioDetailsContentBlock,
self, AudioInfo, AudioMessageEventContent, FileInfo, FileMessageEventContent,
FormattedBody, ImageMessageEventContent, MessageType, UnstableAudioDetailsContentBlock,
UnstableVoiceContentBlock, VideoInfo, VideoMessageEventContent,
},
ImageInfo, MediaSource, ThumbnailInfo,
Expand Down Expand Up @@ -463,7 +463,7 @@ impl Media {
try_join(upload_thumbnail, upload_attachment).await?;

let url = url.to_owned();
let (body, filename)= match caption {
let (body, filename) = match caption {
Some(caption) => (caption, Some(url)),
None => (url, None),
};
Expand Down
46 changes: 23 additions & 23 deletions crates/matrix-sdk/src/room/futures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,26 +267,26 @@ impl<'a> IntoFuture for SendAttachment<'a> {

fn into_future(self) -> Self::IntoFuture {
let Self {
room,
url,
content_type,
data,
config,
caption,
formatted,
tracing_span,
send_progress
room,
url,
content_type,
data,
config,
caption,
formatted,
tracing_span,
send_progress,
} = self;
let fut = async move {
if config.thumbnail.is_some() {
room.prepare_and_send_attachment(
url,
content_type,
data,
config,
caption,
formatted,
send_progress
url,
content_type,
data,
config,
caption,
formatted,
send_progress,
).await
} else {
#[cfg(not(feature = "image-proc"))]
Expand Down Expand Up @@ -346,13 +346,13 @@ impl<'a> IntoFuture for SendAttachment<'a> {
};

room.prepare_and_send_attachment(
url,
content_type,
data,
config,
caption,
formatted,
send_progress
url,
content_type,
data,
config,
caption,
formatted,
send_progress,
).await
}
};
Expand Down
8 changes: 4 additions & 4 deletions crates/matrix-sdk/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,7 @@ impl Room {
#[instrument(skip_all)]
pub async fn enable_encryption(&self) -> Result<()> {
use ruma::{
events::room::encryption::RoomEncryptionEventContent, EventEncryptionAlgorithm,
events::room::encryption::RoomEncryptionEventContent, EventEncryptionAlgorithm,
};
const SYNC_WAIT_TIME: Duration = Duration::from_secs(3);

Expand Down Expand Up @@ -1705,7 +1705,7 @@ impl Room {
/// * `caption` - An optional caption of the media that is going to be
/// uploaded.
///
/// * `formatted` - A optional formatted caption of the media that is going
/// * `formatted` - A optional formatted caption of the media that is going
/// to be uploaded.
///
/// # Examples
Expand Down Expand Up @@ -1770,7 +1770,7 @@ impl Room {
/// media.
///
/// * `config` - Metadata and configuration for the attachment.
///
///
/// * `caption` - An optional caption of the media that is going to be
/// uploaded.
///
Expand Down Expand Up @@ -2871,7 +2871,7 @@ pub struct TryFromReportedContentScoreError(());
mod tests {
use matrix_sdk_base::SessionMeta;
use matrix_sdk_test::{
async_test, test_json, JoinedRoomBuilder, StateTestEvent, SyncResponseBuilder,
async_test, test_json, JoinedRoomBuilder, StateTestEvent, SyncResponseBuilder,
};
use ruma::{device_id, int, user_id};
use wiremock::{
Expand Down
14 changes: 7 additions & 7 deletions crates/matrix-sdk/tests/integration/room/joined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,12 @@ async fn room_attachment_send_wrong_info() {

let response = room
.send_attachment(
"image.jpg",
&mime::IMAGE_JPEG,
b"Hello world".to_vec(),
config,
Some("image caption".to_string()),
None
"image.jpg",
&mime::IMAGE_JPEG,
b"Hello world".to_vec(),
config,
Some("image caption".to_string()),
None,
).await;

response.unwrap_err();
Expand Down Expand Up @@ -555,7 +555,7 @@ async fn room_attachment_send_info_thumbnail() {
}));

let response = room
.send_attachment("image", &mime::IMAGE_JPEG, b"Hello world".to_vec(), config, None, None, )
.send_attachment("image", &mime::IMAGE_JPEG, b"Hello world".to_vec(), config, None, None)
.await
.unwrap();

Expand Down

0 comments on commit 24931fe

Please sign in to comment.