From d1084264f1ec138bf60847cb9f1053befb025104 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 3 Jul 2024 11:58:59 +0200 Subject: [PATCH] !fixup recency timestamp --- crates/matrix-sdk-base/src/sliding_sync.rs | 36 +++++++------------ .../src/store/migration_helpers.rs | 8 +---- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/crates/matrix-sdk-base/src/sliding_sync.rs b/crates/matrix-sdk-base/src/sliding_sync.rs index 51d52e86beb..3bca1564b4b 100644 --- a/crates/matrix-sdk-base/src/sliding_sync.rs +++ b/crates/matrix-sdk-base/src/sliding_sync.rs @@ -1748,12 +1748,9 @@ mod tests { let room_id = room_id!("!r:e.uk"); // When I send sliding sync response containing a room with a recency timestamp - let room = { - let mut room = v4::SlidingSyncRoom::new(); - room.timestamp = Some(MilliSecondsSinceUnixEpoch(42u32.into())); - - room - }; + let room = assign!(v4::SlidingSyncRoom::new(), { + timestamp: Some(MilliSecondsSinceUnixEpoch(42u32.into())), + }); let response = response_with_room(room_id, room); client.process_sliding_sync(&response, &()).await.expect("Failed to process sync"); @@ -1770,12 +1767,9 @@ mod tests { { // When I send sliding sync response containing a room with a recency timestamp - let room = { - let mut room = v4::SlidingSyncRoom::new(); - room.timestamp = Some(MilliSecondsSinceUnixEpoch(42u32.into())); - - room - }; + let room = assign!(v4::SlidingSyncRoom::new(), { + timestamp: Some(MilliSecondsSinceUnixEpoch(42u32.into())), + }); let response = response_with_room(room_id, room); client.process_sliding_sync(&response, &()).await.expect("Failed to process sync"); @@ -1789,12 +1783,9 @@ mod tests { { // When I send sliding sync response containing a room with NO recency timestamp - let room = { - let mut room = v4::SlidingSyncRoom::new(); - room.timestamp = None; - - room - }; + let room = assign!(v4::SlidingSyncRoom::new(), { + timestamp: None, + }); let response = response_with_room(room_id, room); client.process_sliding_sync(&response, &()).await.expect("Failed to process sync"); @@ -1809,12 +1800,9 @@ mod tests { { // When I send sliding sync response containing a room with a NEW recency // timestamp - let room = { - let mut room = v4::SlidingSyncRoom::new(); - room.timestamp = Some(MilliSecondsSinceUnixEpoch(153u32.into())); - - room - }; + let room = assign!(v4::SlidingSyncRoom::new(), { + timestamp: Some(MilliSecondsSinceUnixEpoch(153u32.into())), + }); let response = response_with_room(room_id, room); client.process_sliding_sync(&response, &()).await.expect("Failed to process sync"); diff --git a/crates/matrix-sdk-base/src/store/migration_helpers.rs b/crates/matrix-sdk-base/src/store/migration_helpers.rs index add109cdac2..f4b611b40d1 100644 --- a/crates/matrix-sdk-base/src/store/migration_helpers.rs +++ b/crates/matrix-sdk-base/src/store/migration_helpers.rs @@ -21,8 +21,6 @@ use std::{ #[cfg(feature = "experimental-sliding-sync")] use matrix_sdk_common::deserialized_responses::SyncTimelineEvent; -#[cfg(feature = "experimental-sliding-sync")] -use ruma::MilliSecondsSinceUnixEpoch; use ruma::{ events::{ room::{ @@ -82,8 +80,6 @@ pub struct RoomInfoV1 { #[cfg(feature = "experimental-sliding-sync")] latest_event: Option, base_info: BaseRoomInfoV1, - #[cfg(feature = "experimental-sliding-sync")] - recency_timestamp: Option, } impl RoomInfoV1 { @@ -112,8 +108,6 @@ impl RoomInfoV1 { #[cfg(feature = "experimental-sliding-sync")] latest_event, base_info, - #[cfg(feature = "experimental-sliding-sync")] - recency_timestamp, } = self; RoomInfo { @@ -132,7 +126,7 @@ impl RoomInfoV1 { warned_about_unknown_room_version: Arc::new(false.into()), cached_display_name: None, #[cfg(feature = "experimental-sliding-sync")] - recency_timestamp, + recency_timestamp: None, } } }