mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-04 05:58:11 -04:00
refactor(base): Context derives Default.
This patch makes `Context` to derive `Default`. The `new` constructor also no longer takes a `RoomInfoNotableUpdates`, since it was always used with a default value, it generates this value by itself.
This commit is contained in:
@@ -491,8 +491,7 @@ impl BaseClient {
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
let olm_machine = self.olm_machine().await;
|
||||
|
||||
let mut context =
|
||||
Context::new(StateChanges::new(response.next_batch.clone()), Default::default());
|
||||
let mut context = Context::new(StateChanges::new(response.next_batch.clone()));
|
||||
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
let to_device = {
|
||||
@@ -895,7 +894,7 @@ impl BaseClient {
|
||||
};
|
||||
|
||||
let mut chunk = Vec::with_capacity(response.chunk.len());
|
||||
let mut context = Context::new(StateChanges::default(), Default::default());
|
||||
let mut context = Context::default();
|
||||
|
||||
#[cfg(feature = "e2e-encryption")]
|
||||
let mut user_ids = BTreeSet::new();
|
||||
|
||||
@@ -203,7 +203,7 @@ mod tests {
|
||||
assert!(room.latest_event().is_none());
|
||||
|
||||
// When I tell it to do some decryption
|
||||
let mut context = Context::new(StateChanges::default(), Default::default());
|
||||
let mut context = Context::default();
|
||||
|
||||
decrypt_from_rooms(
|
||||
&mut context,
|
||||
|
||||
@@ -34,17 +34,15 @@ use crate::{RoomInfoNotableUpdateReasons, StateChanges};
|
||||
type RoomInfoNotableUpdates = BTreeMap<OwnedRoomId, RoomInfoNotableUpdateReasons>;
|
||||
|
||||
#[cfg_attr(test, derive(Clone))]
|
||||
#[derive(Default)]
|
||||
pub(crate) struct Context {
|
||||
pub(super) state_changes: StateChanges,
|
||||
pub(super) room_info_notable_updates: RoomInfoNotableUpdates,
|
||||
}
|
||||
|
||||
impl Context {
|
||||
pub fn new(
|
||||
state_changes: StateChanges,
|
||||
room_info_notable_updates: RoomInfoNotableUpdates,
|
||||
) -> Self {
|
||||
Self { state_changes, room_info_notable_updates }
|
||||
pub fn new(state_changes: StateChanges) -> Self {
|
||||
Self { state_changes, room_info_notable_updates: Default::default() }
|
||||
}
|
||||
|
||||
pub fn into_parts(self) -> (StateChanges, RoomInfoNotableUpdates) {
|
||||
|
||||
@@ -2579,7 +2579,7 @@ mod tests {
|
||||
.cast();
|
||||
|
||||
// When the new tag is handled and applied.
|
||||
let mut context = processors::Context::new(StateChanges::default(), Default::default());
|
||||
let mut context = processors::Context::default();
|
||||
|
||||
processors::account_data::for_room(&mut context, room_id, &[tag_raw], &client.state_store)
|
||||
.await;
|
||||
@@ -2675,7 +2675,7 @@ mod tests {
|
||||
.cast();
|
||||
|
||||
// When the new tag is handled and applied.
|
||||
let mut context = processors::Context::new(StateChanges::default(), Default::default());
|
||||
let mut context = processors::Context::default();
|
||||
|
||||
processors::account_data::for_room(&mut context, room_id, &[tag_raw], &client.state_store)
|
||||
.await;
|
||||
@@ -3261,7 +3261,7 @@ mod tests {
|
||||
// And I provide a decrypted event to replace the encrypted one,
|
||||
let event = make_latest_event("$A");
|
||||
|
||||
let mut context = processors::Context::new(StateChanges::default(), Default::default());
|
||||
let mut context = processors::Context::default();
|
||||
room.on_latest_event_decrypted(
|
||||
event.clone(),
|
||||
0,
|
||||
|
||||
@@ -82,7 +82,7 @@ impl BaseClient {
|
||||
|
||||
let olm_machine = self.olm_machine().await;
|
||||
|
||||
let mut context = processors::Context::new(StateChanges::default(), Default::default());
|
||||
let mut context = processors::Context::default();
|
||||
|
||||
let processors::e2ee::to_device::Output { decrypted_to_device_events, room_key_updates } =
|
||||
processors::e2ee::to_device::from_msc4186(
|
||||
@@ -157,7 +157,7 @@ impl BaseClient {
|
||||
return Ok(SyncResponse::default());
|
||||
};
|
||||
|
||||
let mut context = processors::Context::new(StateChanges::default(), Default::default());
|
||||
let mut context = processors::Context::default();
|
||||
|
||||
let state_store = self.state_store.clone();
|
||||
let mut ambiguity_cache = AmbiguityCache::new(state_store.inner.clone());
|
||||
|
||||
Reference in New Issue
Block a user