Skip to content

Commit 7260887

Browse files
committed
feat(sdk): Migrate from SS to SSS.
This patch migrates the code from SS to SSS. It means that `sort` and `bump_event_types` in lists, or room unsubscriptions, in the requests are removed, or `timestamp` migrates to `bump_stamp` etc.
1 parent b61614c commit 7260887

File tree

31 files changed

+331
-551
lines changed

31 files changed

+331
-551
lines changed

bindings/matrix-sdk-ffi/src/room_list.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ use std::{fmt::Debug, mem::MaybeUninit, ptr::addr_of_mut, sync::Arc, time::Durat
33
use eyeball_im::VectorDiff;
44
use futures_util::{pin_mut, StreamExt, TryFutureExt};
55
use matrix_sdk::ruma::{
6-
api::client::sync::sync_events::{
7-
v4::RoomSubscription as RumaRoomSubscription,
8-
UnreadNotificationsCount as RumaUnreadNotificationsCount,
9-
},
6+
api::client::sync::sync_events::UnreadNotificationsCount as RumaUnreadNotificationsCount,
107
assign, RoomId,
118
};
9+
use matrix_sdk::sliding_sync::http;
1210
use matrix_sdk_ui::{
1311
room_list_service::filters::{
1412
new_filter_all, new_filter_any, new_filter_category, new_filter_favourite,
@@ -653,10 +651,6 @@ impl RoomListItem {
653651
self.inner.subscribe(settings.map(Into::into));
654652
}
655653

656-
fn unsubscribe(&self) {
657-
self.inner.unsubscribe();
658-
}
659-
660654
async fn latest_event(&self) -> Option<Arc<EventTimelineItem>> {
661655
self.inner.latest_event().await.map(EventTimelineItem).map(Arc::new)
662656
}
@@ -675,9 +669,9 @@ pub struct RoomSubscription {
675669
pub include_heroes: Option<bool>,
676670
}
677671

678-
impl From<RoomSubscription> for RumaRoomSubscription {
672+
impl From<RoomSubscription> for http::RequestRoomSubscription {
679673
fn from(val: RoomSubscription) -> Self {
680-
assign!(RumaRoomSubscription::default(), {
674+
assign!(http::RequestRoomSubscription::default(), {
681675
required_state: val.required_state.map(|r|
682676
r.into_iter().map(|s| (s.key.into(), s.value)).collect()
683677
).unwrap_or_default(),

crates/matrix-sdk-base/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ experimental-sliding-sync = [
2626
"ruma/unstable-msc3575",
2727
"ruma/unstable-simplified-msc3575",
2828
]
29+
experimental-simplified-sliding-sync = ["experimental-sliding-sync"]
2930
uniffi = ["dep:uniffi", "matrix-sdk-crypto?/uniffi"]
3031

3132
# helpers for testing features build upon this

crates/matrix-sdk-base/src/rooms/normal.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ use bitflags::bitflags;
2424
use eyeball::{SharedObservable, Subscriber};
2525
#[cfg(all(feature = "e2e-encryption", feature = "experimental-sliding-sync"))]
2626
use matrix_sdk_common::ring_buffer::RingBuffer;
27+
#[cfg(feature = "experimental-sliding-sync")]
28+
use ruma::events::AnySyncTimelineEvent;
2729
use ruma::{
2830
api::client::sync::sync_events::v3::RoomSummary as RumaSummary,
2931
events::{
@@ -49,8 +51,6 @@ use ruma::{
4951
EventId, MxcUri, OwnedEventId, OwnedMxcUri, OwnedRoomAliasId, OwnedRoomId, OwnedUserId,
5052
RoomAliasId, RoomId, RoomVersionId, UserId,
5153
};
52-
#[cfg(feature = "experimental-sliding-sync")]
53-
use ruma::{events::AnySyncTimelineEvent, MilliSecondsSinceUnixEpoch};
5454
use serde::{Deserialize, Serialize};
5555
use tokio::sync::broadcast;
5656
use tracing::{debug, field::debug, info, instrument, warn};
@@ -91,8 +91,8 @@ bitflags! {
9191
/// The reason why a [`RoomInfoNotableUpdate`] is emitted.
9292
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
9393
pub struct RoomInfoNotableUpdateReasons: u8 {
94-
/// The recency timestamp of the `Room` has changed.
95-
const RECENCY_TIMESTAMP = 0b0000_0001;
94+
/// The recency stamp of the `Room` has changed.
95+
const RECENCY_STAMP = 0b0000_0001;
9696

9797
/// The latest event of the `Room` has changed.
9898
const LATEST_EVENT = 0b0000_0010;
@@ -920,12 +920,12 @@ impl Room {
920920
self.inner.read().base_info.is_marked_unread
921921
}
922922

923-
/// Returns the recency timestamp of the room.
923+
/// Returns the recency stamp of the room.
924924
///
925-
/// Please read `RoomInfo::recency_timestamp` to learn more.
925+
/// Please read `RoomInfo::recency_stamp` to learn more.
926926
#[cfg(feature = "experimental-sliding-sync")]
927-
pub fn recency_timestamp(&self) -> Option<MilliSecondsSinceUnixEpoch> {
928-
self.inner.read().recency_timestamp
927+
pub fn recency_stamp(&self) -> Option<u64> {
928+
self.inner.read().recency_stamp
929929
}
930930
}
931931

@@ -986,15 +986,15 @@ pub struct RoomInfo {
986986
#[serde(default, skip_serializing_if = "Option::is_none")]
987987
pub(crate) cached_display_name: Option<DisplayName>,
988988

989-
/// The recency timestamp of this room.
989+
/// The recency stamp of this room.
990990
///
991991
/// It's not to be confused with `origin_server_ts` of the latest event.
992992
/// Sliding Sync might "ignore” some events when computing the recency
993-
/// timestamp of the room. Thus, using this `recency_timestamp` value is
993+
/// stamp of the room. Thus, using this `recency_stamp` value is
994994
/// more accurate than relying on the latest event.
995995
#[cfg(feature = "experimental-sliding-sync")]
996996
#[serde(default)]
997-
pub(crate) recency_timestamp: Option<MilliSecondsSinceUnixEpoch>,
997+
pub(crate) recency_stamp: Option<u64>,
998998
}
999999

10001000
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
@@ -1033,7 +1033,7 @@ impl RoomInfo {
10331033
warned_about_unknown_room_version: Arc::new(false.into()),
10341034
cached_display_name: None,
10351035
#[cfg(feature = "experimental-sliding-sync")]
1036-
recency_timestamp: None,
1036+
recency_stamp: None,
10371037
}
10381038
}
10391039

@@ -1439,12 +1439,12 @@ impl RoomInfo {
14391439
self.latest_event.as_deref()
14401440
}
14411441

1442-
/// Updates the recency timestamp of this room.
1442+
/// Updates the recency stamp of this room.
14431443
///
1444-
/// Please read [`Self::recency_timestamp`] to learn more.
1444+
/// Please read [`Self::recency_stamp`] to learn more.
14451445
#[cfg(feature = "experimental-sliding-sync")]
1446-
pub(crate) fn update_recency_timestamp(&mut self, timestamp: MilliSecondsSinceUnixEpoch) {
1447-
self.recency_timestamp = Some(timestamp);
1446+
pub(crate) fn update_recency_stamp(&mut self, stamp: u64) {
1447+
self.recency_stamp = Some(stamp);
14481448
}
14491449
}
14501450

@@ -1660,7 +1660,7 @@ mod tests {
16601660
read_receipts: Default::default(),
16611661
warned_about_unknown_room_version: Arc::new(false.into()),
16621662
cached_display_name: None,
1663-
recency_timestamp: Some(MilliSecondsSinceUnixEpoch(42u32.into())),
1663+
recency_stamp: Some(42),
16641664
};
16651665

16661666
let info_json = json!({
@@ -1713,7 +1713,7 @@ mod tests {
17131713
"latest_active": null,
17141714
"pending": []
17151715
},
1716-
"recency_timestamp": 42,
1716+
"recency_stamp": 42,
17171717
});
17181718

17191719
assert_eq!(serde_json::to_value(info).unwrap(), info_json);

0 commit comments

Comments
 (0)