From 235facb79325edddcf2be2758b3362df0c813236 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 15 Apr 2025 09:41:44 +0200 Subject: [PATCH] refactor(base): `room::sync_v2::update_(joined|left)_room` use `room::Room`. This patch uses the `room::Room` structure in `room::sync_v2` to reduce the number of arguments of the `update_joined_room` and the `update_left_room` processors. --- crates/matrix-sdk-base/src/client.rs | 20 ++++++++----- .../src/response_processors/room/sync_v2.rs | 29 +++++++++++++------ 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/crates/matrix-sdk-base/src/client.rs b/crates/matrix-sdk-base/src/client.rs index 63f22a00d..88c1e2cf9 100644 --- a/crates/matrix-sdk-base/src/client.rs +++ b/crates/matrix-sdk-base/src/client.rs @@ -542,11 +542,13 @@ impl BaseClient { for (room_id, joined_room) in response.rooms.join { let joined_room_update = processors::room::sync_v2::update_joined_room( &mut context, - &room_id, + processors::room::Room::new( + &room_id, + self.room_info_notable_update_sender.clone(), + requested_required_states, + &mut ambiguity_cache, + ), joined_room, - requested_required_states, - self.room_info_notable_update_sender.clone(), - &mut ambiguity_cache, &mut updated_members_in_room, processors::notification::Notification::new( &push_rules, @@ -568,11 +570,13 @@ impl BaseClient { for (room_id, left_room) in response.rooms.leave { let left_room_update = processors::room::sync_v2::update_left_room( &mut context, - &room_id, + processors::room::Room::new( + &room_id, + self.room_info_notable_update_sender.clone(), + requested_required_states, + &mut ambiguity_cache, + ), left_room, - requested_required_states, - self.room_info_notable_update_sender.clone(), - &mut ambiguity_cache, processors::notification::Notification::new( &push_rules, &mut notifications, diff --git a/crates/matrix-sdk-base/src/response_processors/room/sync_v2.rs b/crates/matrix-sdk-base/src/response_processors/room/sync_v2.rs index d037b231e..f02762c5d 100644 --- a/crates/matrix-sdk-base/src/response_processors/room/sync_v2.rs +++ b/crates/matrix-sdk-base/src/response_processors/room/sync_v2.rs @@ -22,7 +22,10 @@ use tokio::sync::broadcast::Sender; #[cfg(feature = "e2e-encryption")] use super::super::e2ee; -use super::super::{account_data, ephemeral_events, notification, state_events, timeline, Context}; +use super::{ + super::{account_data, ephemeral_events, notification, state_events, timeline, Context}, + Room as RoomCreationData, +}; use crate::{ store::ambiguity_map::AmbiguityCache, sync::{InvitedRoomUpdate, JoinedRoomUpdate, KnockedRoomUpdate, LeftRoomUpdate}, @@ -33,15 +36,19 @@ use crate::{ #[allow(clippy::too_many_arguments)] pub async fn update_joined_room( context: &mut Context, - room_id: &RoomId, + room_creation_data: RoomCreationData<'_>, joined_room: JoinedRoom, - requested_required_states: &RequestedRequiredStates, - room_info_notable_update_sender: Sender, - ambiguity_cache: &mut AmbiguityCache, updated_members_in_room: &mut BTreeMap>, notification: notification::Notification<'_>, #[cfg(feature = "e2e-encryption")] e2ee: e2ee::E2EE<'_>, ) -> Result { + let RoomCreationData { + room_id, + room_info_notable_update_sender, + requested_required_states, + ambiguity_cache, + } = room_creation_data; + let state_store = notification.state_store; let room = @@ -147,14 +154,18 @@ pub async fn update_joined_room( #[allow(clippy::too_many_arguments)] pub async fn update_left_room( context: &mut Context, - room_id: &RoomId, + room_creation_data: RoomCreationData<'_>, left_room: LeftRoom, - requested_required_states: &RequestedRequiredStates, - room_info_notable_update_sender: Sender, - ambiguity_cache: &mut AmbiguityCache, notification: notification::Notification<'_>, #[cfg(feature = "e2e-encryption")] e2ee: e2ee::E2EE<'_>, ) -> Result { + let RoomCreationData { + room_id, + room_info_notable_update_sender, + requested_required_states, + ambiguity_cache, + } = room_creation_data; + let state_store = notification.state_store; let room =