Skip to content

Commit

Permalink
refactor: send respects to multiple automated lints and checks
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjbvr committed Jan 22, 2025
1 parent 041627e commit 2d0f873
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
2 changes: 2 additions & 0 deletions crates/matrix-sdk-common/src/deserialized_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

use std::{collections::BTreeMap, fmt};

#[cfg(doc)]
use ruma::events::AnyTimelineEvent;
use ruma::{
events::{AnyMessageLikeEvent, AnySyncTimelineEvent},
push::Action,
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk-ui/src/timeline/controller/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl TimelineState {

let handle_one_res = txn
.handle_remote_event(
event.into(),
event,
TimelineItemPosition::UpdateAt { timeline_item_index: idx },
room_data_provider,
settings,
Expand Down Expand Up @@ -759,7 +759,7 @@ impl TimelineStateTransaction<'_> {
},
is_highlighted: push_actions
.as_ref()
.map_or(false, |actions| actions.iter().any(Action::is_highlight)),
.is_some_and(|actions| actions.iter().any(Action::is_highlight)),
flow: Flow::Remote {
event_id: event_id.clone(),
raw_event: raw,
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk-ui/src/timeline/pinned_events_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl PinnedEventsRoom for Room {
debug!("Loading pinned event {event_id} from HS");
self.event(event_id, request_config)
.await
.map(|e| (e.into(), Vec::new()))
.map(|e| (e, Vec::new()))
.map_err(|err| PaginatorError::SdkError(Box::new(err)))
})
}
Expand Down
14 changes: 9 additions & 5 deletions crates/matrix-sdk/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,11 @@ impl Room {
start: http_response.start,
end: http_response.end,
#[cfg(not(feature = "e2e-encryption"))]
chunk: http_response.chunk.into_iter().map(TimelineEvent::new).collect(),
chunk: http_response
.chunk
.into_iter()
.map(|raw| TimelineEvent::new(raw.cast()))
.collect(),
#[cfg(feature = "e2e-encryption")]
chunk: Vec::with_capacity(http_response.chunk.len()),
state: http_response.state,
Expand Down Expand Up @@ -481,7 +485,7 @@ impl Room {

// Save the event into the event cache, if it's set up.
if let Ok((cache, _handles)) = self.event_cache().await {
cache.save_event(event.clone().into()).await;
cache.save_event(event.clone()).await;
}

Ok(event)
Expand Down Expand Up @@ -527,15 +531,15 @@ impl Room {
if let Ok((cache, _handles)) = self.event_cache().await {
let mut events_to_save: Vec<TimelineEvent> = Vec::new();
if let Some(event) = &target_event {
events_to_save.push(event.clone().into());
events_to_save.push(event.clone());
}

for event in &events_before {
events_to_save.push(event.clone().into());
events_to_save.push(event.clone());
}

for event in &events_after {
events_to_save.push(event.clone().into());
events_to_save.push(event.clone());
}

cache.save_events(events_to_save).await;
Expand Down
7 changes: 2 additions & 5 deletions crates/matrix-sdk/src/sliding_sync/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ mod tests {
}))
.unwrap()
.cast()
).into()
)
};
}

Expand Down Expand Up @@ -616,8 +616,7 @@ mod tests {
}))
.unwrap()
.cast(),
)
.into()],
)],
};

let serialized = serde_json::to_value(&frozen_room).unwrap();
Expand Down Expand Up @@ -669,7 +668,6 @@ mod tests {
.unwrap()
.cast(),
)
.into()
})
.collect::<Vec<_>>();

Expand Down Expand Up @@ -706,7 +704,6 @@ mod tests {
.unwrap()
.cast(),
)
.into()
})
.collect::<Vec<_>>();

Expand Down

0 comments on commit 2d0f873

Please sign in to comment.