@@ -47,7 +47,9 @@ use tracing::{Instrument, Level, Span, error, info, instrument, trace, warn};
4747
4848use crate :: {
4949 encryption_sync_service:: { self , EncryptionSyncPermit , EncryptionSyncService } ,
50- room_list_service:: { self , RoomListService } ,
50+ room_list_service:: {
51+ self , DEFAULT_ROOM_LIST_CONN_ID , DEFAULT_ROOM_LIST_TIMELINE_LIMIT , RoomListService ,
52+ } ,
5153} ;
5254
5355/// Current state of the application.
@@ -774,6 +776,15 @@ pub struct SyncServiceBuilder {
774776 /// [`SlidingSyncBuilder::share_pos`]: matrix_sdk::sliding_sync::SlidingSyncBuilder::share_pos
775777 with_share_pos : bool ,
776778
779+ /// Custom connection ID for the room list service.
780+ /// Defaults to "room-list". Use a different value for
781+ /// secondary processes such as iOS share extensions that are not
782+ /// meant to reuse the main app's connection.
783+ room_list_conn_id : String ,
784+
785+ /// Custom timeline limit for the room list service. Defaults to 1.
786+ room_list_timeline_limit : u32 ,
787+
777788 /// The parent tracing span to use for the tasks within this service.
778789 ///
779790 /// Normally this will be [`Span::none`], but it may be useful to assign a
@@ -784,7 +795,14 @@ pub struct SyncServiceBuilder {
784795
785796impl SyncServiceBuilder {
786797 fn new ( client : Client ) -> Self {
787- Self { client, with_offline_mode : false , with_share_pos : true , parent_span : Span :: none ( ) }
798+ Self {
799+ client,
800+ with_offline_mode : false ,
801+ with_share_pos : true ,
802+ room_list_conn_id : DEFAULT_ROOM_LIST_CONN_ID . to_owned ( ) ,
803+ room_list_timeline_limit : DEFAULT_ROOM_LIST_TIMELINE_LIMIT ,
804+ parent_span : Span :: none ( ) ,
805+ }
788806 }
789807
790808 /// Enable the "offline" mode for the [`SyncService`].
@@ -804,6 +822,18 @@ impl SyncServiceBuilder {
804822 self
805823 }
806824
825+ /// Set a custom conn_id for the room list sliding sync connection.
826+ pub fn with_room_list_conn_id ( mut self , conn_id : String ) -> Self {
827+ self . room_list_conn_id = conn_id;
828+ self
829+ }
830+
831+ /// Set a custom timeline limit for the room list service.
832+ pub fn with_room_list_timeline_limit ( mut self , limit : u32 ) -> Self {
833+ self . room_list_timeline_limit = limit;
834+ self
835+ }
836+
807837 /// Set the parent tracing span to be used for the tasks within this
808838 /// service.
809839 pub fn with_parent_span ( mut self , parent_span : Span ) -> Self {
@@ -817,11 +847,24 @@ impl SyncServiceBuilder {
817847 /// the background. The resulting [`SyncService`] must be kept alive as long
818848 /// as the sliding syncs are supposed to run.
819849 pub async fn build ( self ) -> Result < SyncService , Error > {
820- let Self { client, with_offline_mode, with_share_pos, parent_span } = self ;
850+ let Self {
851+ client,
852+ with_offline_mode,
853+ with_share_pos,
854+ room_list_conn_id,
855+ room_list_timeline_limit,
856+ parent_span,
857+ } = self ;
821858
822859 let encryption_sync_permit = Arc :: new ( AsyncMutex :: new ( EncryptionSyncPermit :: new ( ) ) ) ;
823860
824- let room_list = RoomListService :: new_with_share_pos ( client. clone ( ) , with_share_pos) . await ?;
861+ let room_list = RoomListService :: new_with_share_pos (
862+ client. clone ( ) ,
863+ with_share_pos,
864+ & room_list_conn_id,
865+ room_list_timeline_limit,
866+ )
867+ . await ?;
825868
826869 let encryption_sync = Arc :: new ( EncryptionSyncService :: new ( client, None ) . await ?) ;
827870
0 commit comments