diff --git a/bindings/matrix-sdk-ffi/src/api.udl b/bindings/matrix-sdk-ffi/src/api.udl index 1d1f9b74ee9..22b0566b125 100644 --- a/bindings/matrix-sdk-ffi/src/api.udl +++ b/bindings/matrix-sdk-ffi/src/api.udl @@ -198,3 +198,13 @@ interface RoomListEntriesUpdate { callback interface RoomListEntriesListener { void on_update(RoomListEntriesUpdate room_entries_update); }; + +[Enum] +interface RoomListInput { + Viewport(sequence ranges); +}; + +dictionary RoomListRange { + u32 start; + u32 end_inclusive; +}; diff --git a/bindings/matrix-sdk-ffi/src/room_list.rs b/bindings/matrix-sdk-ffi/src/room_list.rs index 213c49f4942..bfa3abffbf4 100644 --- a/bindings/matrix-sdk-ffi/src/room_list.rs +++ b/bindings/matrix-sdk-ffi/src/room_list.rs @@ -54,6 +54,25 @@ impl From for RoomListError { } } +pub struct RoomListRange { + pub start: u32, + pub end_inclusive: u32, +} + +pub enum RoomListInput { + Viewport { ranges: Vec }, +} + +impl From for matrix_sdk_ui::room_list::Input { + fn from(value: RoomListInput) -> Self { + match value { + RoomListInput::Viewport { ranges } => Self::Viewport( + ranges.iter().map(|range| range.start..=range.end_inclusive).collect(), + ), + } + } +} + #[derive(uniffi::Object)] pub struct RoomList { inner: Arc, @@ -104,6 +123,10 @@ impl RoomList { }) } + async fn apply_input(&self, input: RoomListInput) -> Result<(), RoomListError> { + self.inner.apply_input(input.into()).await.map_err(Into::into) + } + fn room(&self, room_id: String) -> Result, RoomListError> { let room_id = <&RoomId>::try_from(room_id.as_str()).map_err(RoomListError::from)?; diff --git a/crates/matrix-sdk-ui/tests/integration/room_list.rs b/crates/matrix-sdk-ui/tests/integration/room_list.rs index b610e18712e..0422aaa6cd6 100644 --- a/crates/matrix-sdk-ui/tests/integration/room_list.rs +++ b/crates/matrix-sdk-ui/tests/integration/room_list.rs @@ -1573,8 +1573,8 @@ async fn test_input_viewport() -> Result<(), Error> { VISIBLE_ROOMS: { "ranges": [], "timeline_limit": 20, - } - } + }, + }, }, respond with = { "pos": "1", @@ -1596,8 +1596,8 @@ async fn test_input_viewport() -> Result<(), Error> { VISIBLE_ROOMS: { "ranges": [[10, 15], [20, 25]], "timeline_limit": 20, - } - } + }, + }, }, respond with = { "pos": "1",