diff --git a/bindings/matrix-sdk-ffi/src/sync_service.rs b/bindings/matrix-sdk-ffi/src/sync_service.rs index 296bf7480..9b5d66805 100644 --- a/bindings/matrix-sdk-ffi/src/sync_service.rs +++ b/bindings/matrix-sdk-ffi/src/sync_service.rs @@ -119,6 +119,12 @@ impl SyncServiceBuilder { Arc::new(Self { builder, ..this }) } + pub fn with_share_pos(self: Arc, enable: bool) -> Arc { + let this = unwrap_or_clone_arc(self); + let builder = this.builder.with_share_pos(enable); + Arc::new(Self { builder, ..this }) + } + pub async fn finish(self: Arc) -> Result, ClientError> { let this = unwrap_or_clone_arc(self); Ok(Arc::new(SyncService { diff --git a/crates/matrix-sdk-ui/src/room_list_service/mod.rs b/crates/matrix-sdk-ui/src/room_list_service/mod.rs index 2a840c1b2..412ea080a 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/mod.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/mod.rs @@ -131,7 +131,15 @@ impl RoomListService { /// to create one in this case using /// [`EncryptionSyncService`][crate::encryption_sync_service::EncryptionSyncService]. pub async fn new(client: Client) -> Result { - let builder = client + Self::new_with_share_pos(client, true).await + } + + /// Like [`RoomListService::new`] but with a flag to turn the + /// [`SlidingSyncBuilder::share_pos`] on and off. + /// + /// [`SlidingSyncBuilder::share_pos`]: matrix_sdk::sliding_sync::SlidingSyncBuilder::share_pos + pub async fn new_with_share_pos(client: Client, share_pos: bool) -> Result { + let mut builder = client .sliding_sync("room-list") .map_err(Error::SlidingSync)? .with_account_data_extension( @@ -143,9 +151,12 @@ impl RoomListService { })) .with_typing_extension(assign!(http::request::Typing::default(), { enabled: Some(true), - })) + })); + + if share_pos { // We don't deal with encryption device messages here so this is safe - .share_pos(); + builder = builder.share_pos(); + } let sliding_sync = builder .add_cached_list( diff --git a/crates/matrix-sdk-ui/src/sync_service.rs b/crates/matrix-sdk-ui/src/sync_service.rs index 1390f30ac..8ad54f719 100644 --- a/crates/matrix-sdk-ui/src/sync_service.rs +++ b/crates/matrix-sdk-ui/src/sync_service.rs @@ -763,6 +763,11 @@ pub struct SyncServiceBuilder { /// The offline mode is described in the [`State::Offline`] enum variant. with_offline_mode: bool, + /// Whether to turn [`SlidingSyncBuilder::share_pos`] on or off. + /// + /// [`SlidingSyncBuilder::share_pos`]: matrix_sdk::sliding_sync::SlidingSyncBuilder::share_pos + with_share_pos: bool, + /// The parent tracing span to use for the tasks within this service. /// /// Normally this will be [`Span::none`], but it may be useful to assign a @@ -777,6 +782,7 @@ impl SyncServiceBuilder { client, with_cross_process_lock: false, with_offline_mode: false, + with_share_pos: true, parent_span: Span::none(), } } @@ -805,6 +811,14 @@ impl SyncServiceBuilder { self } + /// Whether to turn [`SlidingSyncBuilder::share_pos`] on or off. + /// + /// [`SlidingSyncBuilder::share_pos`]: matrix_sdk::sliding_sync::SlidingSyncBuilder::share_pos + pub fn with_share_pos(mut self, enable: bool) -> Self { + self.with_share_pos = enable; + self + } + /// Set the parent tracing span to be used for the tasks within this /// service. pub fn with_parent_span(mut self, parent_span: Span) -> Self { @@ -818,11 +832,17 @@ impl SyncServiceBuilder { /// the background. The resulting [`SyncService`] must be kept alive as long /// as the sliding syncs are supposed to run. pub async fn build(self) -> Result { - let Self { client, with_cross_process_lock, with_offline_mode, parent_span } = self; + let Self { + client, + with_cross_process_lock, + with_offline_mode, + with_share_pos, + parent_span, + } = self; let encryption_sync_permit = Arc::new(AsyncMutex::new(EncryptionSyncPermit::new())); - let room_list = RoomListService::new(client.clone()).await?; + let room_list = RoomListService::new_with_share_pos(client.clone(), with_share_pos).await?; let encryption_sync = Arc::new( EncryptionSyncService::new(client, None, WithLocking::from(with_cross_process_lock))