refactor(ffi): also pass the UTD hook to the notification client

This commit is contained in:
Benjamin Bouvier
2025-05-21 15:13:11 +02:00
parent 820c73dd2f
commit cd76cec089
2 changed files with 5 additions and 4 deletions

View File

@@ -220,7 +220,7 @@ impl From<matrix_sdk::TransmissionProgress> for TransmissionProgress {
pub struct Client {
pub(crate) inner: AsyncRuntimeDropped<MatrixClient>,
delegate: OnceLock<Arc<dyn ClientDelegate>>,
utd_hook_manager: OnceLock<Arc<UtdHookManager>>,
pub(crate) utd_hook_manager: OnceLock<Arc<UtdHookManager>>,
session_verification_controller:
Arc<tokio::sync::RwLock<Option<SessionVerificationController>>>,
}
@@ -1141,7 +1141,7 @@ impl Client {
Ok(Arc::new(NotificationClient {
inner: MatrixNotificationClient::new((*self.inner).clone(), process_setup.into())
.await?,
_client: self.clone(),
client: self.clone(),
}))
}

View File

@@ -96,7 +96,7 @@ pub struct NotificationClient {
/// Note: we do this to make it so that the FFI `NotificationClient` keeps
/// the FFI `Client` and thus the SDK `Client` alive. Otherwise, we
/// would need to repeat the hack done in the FFI `Client::drop` method.
pub(crate) _client: Arc<Client>,
pub(crate) client: Arc<Client>,
}
#[matrix_sdk_ffi_macros::export]
@@ -108,7 +108,8 @@ impl NotificationClient {
pub fn get_room(&self, room_id: String) -> Result<Option<Arc<Room>>, ClientError> {
let room_id = RoomId::parse(room_id)?;
let sdk_room = self.inner.get_room(&room_id);
let room = sdk_room.map(|room| Arc::new(Room::new(room, None)));
let room = sdk_room
.map(|room| Arc::new(Room::new(room, self.client.utd_hook_manager.get().cloned())));
Ok(room)
}