Skip to content

Commit 284db61

Browse files
committed
feat(ffi): expose a new get_room method on the NotificationClient that will fetch it from its inner in-memory store backed client instead of the parent one.
This is necessary because the `NotificationClient` runs a sliding sync loop and the retrieved data isn't pushed back into the parent client stores (because of cross process locking shenanigans). This will be used with the previously introduced `org.matrix.msc3401.call.member` required state to check whether a room still has an ongoing call before showing the ringing screen.
1 parent 8e19a5e commit 284db61

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::{
99
client::{Client, JoinRule},
1010
error::ClientError,
1111
event::TimelineEvent,
12+
room::Room,
1213
};
1314

1415
#[derive(uniffi::Enum)]
@@ -99,6 +100,17 @@ pub struct NotificationClient {
99100

100101
#[matrix_sdk_ffi_macros::export]
101102
impl NotificationClient {
103+
/// Fetches a room by its ID using the in-memory state store backed client.
104+
///
105+
/// Useful to retrieve room information after running the limited
106+
/// notification client sliding sync loop.
107+
pub fn get_room(&self, room_id: String) -> Result<Option<Arc<Room>>, ClientError> {
108+
let room_id = RoomId::parse(room_id)?;
109+
let sdk_room = self.inner.get_room(&room_id);
110+
let room = sdk_room.map(|room| Arc::new(Room::new(room)));
111+
Ok(room)
112+
}
113+
102114
/// See also documentation of
103115
/// `MatrixNotificationClient::get_notification`.
104116
pub async fn get_notification(

crates/matrix-sdk-ui/src/notification_client.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ impl NotificationClient {
125125
})
126126
}
127127

128+
/// Fetches a room by its ID using the in-memory state store backed client.
129+
/// Useful to retrieve room information after running the limited
130+
/// notification client sliding sync loop.
131+
pub fn get_room(&self, room_id: &RoomId) -> Option<Room> {
132+
self.client.get_room(room_id)
133+
}
134+
128135
/// Fetches the content of a notification.
129136
///
130137
/// This will first try to get the notification using a short-lived sliding

0 commit comments

Comments
 (0)