From ab363aa4204d358efbb4a68e4d0cb8225c2c28b4 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Mon, 24 Jul 2023 17:48:27 +0200 Subject: [PATCH] chore: slim down `UpdateSummary` --- crates/matrix-sdk/src/sliding_sync/mod.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/crates/matrix-sdk/src/sliding_sync/mod.rs b/crates/matrix-sdk/src/sliding_sync/mod.rs index 97ed9c073..137593233 100644 --- a/crates/matrix-sdk/src/sliding_sync/mod.rs +++ b/crates/matrix-sdk/src/sliding_sync/mod.rs @@ -267,7 +267,7 @@ impl SlidingSync { async fn handle_response( &self, mut sliding_sync_response: v4::Response, - ) -> Result { + ) -> Result<(UpdateSummary, Option), crate::Error> { { let known_rooms = self.inner.rooms.read().await; compute_limited(&known_rooms, &mut sliding_sync_response.rooms); @@ -393,17 +393,12 @@ impl SlidingSync { updated_lists }; - UpdateSummary { - lists: updated_lists, - rooms: updated_rooms, - to_device_token: sliding_sync_response - .extensions - .to_device - .map(|ext| ext.next_batch), - } + UpdateSummary { lists: updated_lists, rooms: updated_rooms } }; - Ok(update_summary) + let to_device_token = sliding_sync_response.extensions.to_device.map(|ext| ext.next_batch); + + Ok((update_summary, to_device_token)) } async fn generate_sync_request( @@ -610,9 +605,9 @@ impl SlidingSync { } // Handle the response. - let updates = this.handle_response(response).await?; + let (updates, to_device_token) = this.handle_response(response).await?; - this.cache_to_storage(updates.to_device_token.clone()).await?; + this.cache_to_storage(to_device_token).await?; // Release the lock. drop(response_handling_lock); @@ -820,8 +815,6 @@ pub struct UpdateSummary { pub lists: Vec, /// The rooms that have seen updates pub rooms: Vec, - /// The `prev_batch` token from the ToDevice extension, if any. - pub to_device_token: Option, } /// The set of sticky parameters owned by the `SlidingSyncInner` instance, and