Skip to content

Commit ed08fc4

Browse files
committed
change(ffi): remove the UTD manager from the sync service, room list service and room list items
1 parent 1b4bd26 commit ed08fc4

File tree

2 files changed

+19
-55
lines changed

2 files changed

+19
-55
lines changed

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

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use matrix_sdk_ui::{
1717
new_filter_unread, BoxedFilterFn, RoomCategory,
1818
},
1919
timeline::default_event_filter,
20-
unable_to_decrypt_hook::UtdHookManager,
2120
};
2221
use ruma::{OwnedRoomOrAliasId, OwnedServerName, ServerName};
2322
use tokio::sync::RwLock;
@@ -84,7 +83,6 @@ impl From<ruma::IdParseError> for RoomListError {
8483
#[derive(uniffi::Object)]
8584
pub struct RoomListService {
8685
pub(crate) inner: Arc<matrix_sdk_ui::RoomListService>,
87-
pub(crate) utd_hook: Option<Arc<UtdHookManager>>,
8886
}
8987

9088
#[matrix_sdk_ffi_macros::export]
@@ -104,10 +102,7 @@ impl RoomListService {
104102
fn room(&self, room_id: String) -> Result<Arc<RoomListItem>, RoomListError> {
105103
let room_id = <&RoomId>::try_from(room_id.as_str()).map_err(RoomListError::from)?;
106104

107-
Ok(Arc::new(RoomListItem {
108-
inner: Arc::new(self.inner.room(room_id)?),
109-
utd_hook: self.utd_hook.clone(),
110-
}))
105+
Ok(Arc::new(RoomListItem { inner: Arc::new(self.inner.room(room_id)?) }))
111106
}
112107

113108
async fn all_rooms(self: Arc<Self>) -> Result<Arc<RoomList>, RoomListError> {
@@ -183,7 +178,6 @@ impl RoomList {
183178
listener: Box<dyn RoomListEntriesListener>,
184179
) -> Arc<RoomListEntriesWithDynamicAdaptersResult> {
185180
let this = self.clone();
186-
let utd_hook = self.room_list_service.utd_hook.clone();
187181

188182
// The following code deserves a bit of explanation.
189183
// `matrix_sdk_ui::room_list_service::RoomList::entries_with_dynamic_adapters`
@@ -242,10 +236,7 @@ impl RoomList {
242236

243237
while let Some(diffs) = entries_stream.next().await {
244238
listener.on_update(
245-
diffs
246-
.into_iter()
247-
.map(|diff| RoomListEntriesUpdate::from(diff, utd_hook.clone()))
248-
.collect(),
239+
diffs.into_iter().map(|diff| RoomListEntriesUpdate::from(diff)).collect(),
249240
);
250241
}
251242
})));
@@ -392,33 +383,30 @@ pub enum RoomListEntriesUpdate {
392383
}
393384

394385
impl RoomListEntriesUpdate {
395-
fn from(
396-
vector_diff: VectorDiff<matrix_sdk_ui::room_list_service::Room>,
397-
utd_hook: Option<Arc<UtdHookManager>>,
398-
) -> Self {
386+
fn from(vector_diff: VectorDiff<matrix_sdk_ui::room_list_service::Room>) -> Self {
399387
match vector_diff {
400388
VectorDiff::Append { values } => Self::Append {
401389
values: values
402390
.into_iter()
403-
.map(|value| Arc::new(RoomListItem::from(value, utd_hook.clone())))
391+
.map(|value| Arc::new(RoomListItem::from(value)))
404392
.collect(),
405393
},
406394
VectorDiff::Clear => Self::Clear,
407395
VectorDiff::PushFront { value } => {
408-
Self::PushFront { value: Arc::new(RoomListItem::from(value, utd_hook)) }
396+
Self::PushFront { value: Arc::new(RoomListItem::from(value)) }
409397
}
410398
VectorDiff::PushBack { value } => {
411-
Self::PushBack { value: Arc::new(RoomListItem::from(value, utd_hook)) }
399+
Self::PushBack { value: Arc::new(RoomListItem::from(value)) }
412400
}
413401
VectorDiff::PopFront => Self::PopFront,
414402
VectorDiff::PopBack => Self::PopBack,
415403
VectorDiff::Insert { index, value } => Self::Insert {
416404
index: u32::try_from(index).unwrap(),
417-
value: Arc::new(RoomListItem::from(value, utd_hook)),
405+
value: Arc::new(RoomListItem::from(value)),
418406
},
419407
VectorDiff::Set { index, value } => Self::Set {
420408
index: u32::try_from(index).unwrap(),
421-
value: Arc::new(RoomListItem::from(value, utd_hook)),
409+
value: Arc::new(RoomListItem::from(value)),
422410
},
423411
VectorDiff::Remove { index } => Self::Remove { index: u32::try_from(index).unwrap() },
424412
VectorDiff::Truncate { length } => {
@@ -427,7 +415,7 @@ impl RoomListEntriesUpdate {
427415
VectorDiff::Reset { values } => Self::Reset {
428416
values: values
429417
.into_iter()
430-
.map(|value| Arc::new(RoomListItem::from(value, utd_hook.clone())))
418+
.map(|value| Arc::new(RoomListItem::from(value)))
431419
.collect(),
432420
},
433421
}
@@ -528,15 +516,11 @@ impl From<RoomListEntriesDynamicFilterKind> for BoxedFilterFn {
528516
#[derive(uniffi::Object)]
529517
pub struct RoomListItem {
530518
inner: Arc<matrix_sdk_ui::room_list_service::Room>,
531-
utd_hook: Option<Arc<UtdHookManager>>,
532519
}
533520

534521
impl RoomListItem {
535-
fn from(
536-
value: matrix_sdk_ui::room_list_service::Room,
537-
utd_hook: Option<Arc<UtdHookManager>>,
538-
) -> Self {
539-
Self { inner: Arc::new(value), utd_hook }
522+
fn from(value: matrix_sdk_ui::room_list_service::Room) -> Self {
523+
Self { inner: Arc::new(value) }
540524
}
541525
}
542526

@@ -667,10 +651,6 @@ impl RoomListItem {
667651
timeline_builder = timeline_builder.with_internal_id_prefix(internal_id_prefix);
668652
}
669653

670-
if let Some(utd_hook) = self.utd_hook.clone() {
671-
timeline_builder = timeline_builder.with_unable_to_decrypt_hook(utd_hook);
672-
}
673-
674654
self.inner.init_timeline_with_builder(timeline_builder).map_err(RoomListError::from).await
675655
}
676656

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

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ use std::{fmt::Debug, sync::Arc};
1717
use async_compat::get_runtime_handle;
1818
use futures_util::pin_mut;
1919
use matrix_sdk::Client;
20-
use matrix_sdk_ui::{
21-
sync_service::{
22-
State as MatrixSyncServiceState, SyncService as MatrixSyncService,
23-
SyncServiceBuilder as MatrixSyncServiceBuilder,
24-
},
25-
unable_to_decrypt_hook::UtdHookManager,
20+
use matrix_sdk_ui::sync_service::{
21+
State as MatrixSyncServiceState, SyncService as MatrixSyncService,
22+
SyncServiceBuilder as MatrixSyncServiceBuilder,
2623
};
2724

2825
use crate::{
@@ -58,16 +55,12 @@ pub trait SyncServiceStateObserver: Send + Sync + Debug {
5855
#[derive(uniffi::Object)]
5956
pub struct SyncService {
6057
pub(crate) inner: Arc<MatrixSyncService>,
61-
utd_hook: Option<Arc<UtdHookManager>>,
6258
}
6359

6460
#[matrix_sdk_ffi_macros::export]
6561
impl SyncService {
6662
pub fn room_list_service(&self) -> Arc<RoomListService> {
67-
Arc::new(RoomListService {
68-
inner: self.inner.room_list_service(),
69-
utd_hook: self.utd_hook.clone(),
70-
})
63+
Arc::new(RoomListService { inner: self.inner.room_list_service() })
7164
}
7265

7366
pub async fn start(&self) {
@@ -95,17 +88,11 @@ impl SyncService {
9588
pub struct SyncServiceBuilder {
9689
client: Client,
9790
builder: MatrixSyncServiceBuilder,
98-
99-
utd_hook: Option<Arc<UtdHookManager>>,
10091
}
10192

10293
impl SyncServiceBuilder {
10394
pub(crate) fn new(client: Client) -> Arc<Self> {
104-
Arc::new(Self {
105-
client: client.clone(),
106-
builder: MatrixSyncService::builder(client),
107-
utd_hook: None,
108-
})
95+
Arc::new(Self { client: client.clone(), builder: MatrixSyncService::builder(client) })
10996
}
11097
}
11198

@@ -114,21 +101,18 @@ impl SyncServiceBuilder {
114101
pub fn with_cross_process_lock(self: Arc<Self>) -> Arc<Self> {
115102
let this = unwrap_or_clone_arc(self);
116103
let builder = this.builder.with_cross_process_lock();
117-
Arc::new(Self { client: this.client, builder, utd_hook: this.utd_hook })
104+
Arc::new(Self { client: this.client, builder })
118105
}
119106

120107
/// Enable the "offline" mode for the [`SyncService`].
121108
pub fn with_offline_mode(self: Arc<Self>) -> Arc<Self> {
122109
let this = unwrap_or_clone_arc(self);
123110
let builder = this.builder.with_offline_mode();
124-
Arc::new(Self { client: this.client, builder, utd_hook: this.utd_hook })
111+
Arc::new(Self { client: this.client, builder })
125112
}
126113

127114
pub async fn finish(self: Arc<Self>) -> Result<Arc<SyncService>, ClientError> {
128115
let this = unwrap_or_clone_arc(self);
129-
Ok(Arc::new(SyncService {
130-
inner: Arc::new(this.builder.build().await?),
131-
utd_hook: this.utd_hook,
132-
}))
116+
Ok(Arc::new(SyncService { inner: Arc::new(this.builder.build().await?) }))
133117
}
134118
}

0 commit comments

Comments
 (0)