Skip to content

Commit

Permalink
chore(ui,ffi): Remove the RoomList::entries method.
Browse files Browse the repository at this point in the history
This method is now private inside `matrix_sdk_ui` and removed
from `matrix_sdk_ffi`. This method is returning a stream of rooms,
but updates on rooms won't update the stream (only new rooms
will be seen on the stream). Nobody uses it as far as I know, and
`entries_with_dynamic_adapters` is the real only API we want people
to use.
  • Loading branch information
Hywan committed Sep 16, 2024
1 parent a9ed622 commit b74a8c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 32 deletions.
27 changes: 0 additions & 27 deletions bindings/matrix-sdk-ffi/src/room_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,33 +182,6 @@ impl RoomList {
})
}

fn entries(&self, listener: Box<dyn RoomListEntriesListener>) -> Arc<TaskHandle> {
let this = self.inner.clone();
let utd_hook = self.room_list_service.utd_hook.clone();

Arc::new(TaskHandle::new(RUNTIME.spawn(async move {
let (entries, entries_stream) = this.entries();

pin_mut!(entries_stream);

listener.on_update(vec![RoomListEntriesUpdate::Append {
values: entries
.into_iter()
.map(|room| Arc::new(RoomListItem::from(room, utd_hook.clone())))
.collect(),
}]);

while let Some(diffs) = entries_stream.next().await {
listener.on_update(
diffs
.into_iter()
.map(|diff| RoomListEntriesUpdate::from(diff, utd_hook.clone()))
.collect(),
);
}
})))
}

fn entries_with_dynamic_adapters(
self: Arc<Self>,
page_size: u32,
Expand Down
12 changes: 7 additions & 5 deletions crates/matrix-sdk-ui/src/room_list_service/room_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ impl RoomList {
self.loading_state.subscribe()
}

/// Get all previous rooms, in addition to a [`Stream`] to rooms' updates.
pub fn entries(&self) -> (Vector<Room>, impl Stream<Item = Vec<VectorDiff<Room>>> + '_) {
/// Get a stream of rooms.
fn entries(&self) -> (Vector<Room>, impl Stream<Item = Vec<VectorDiff<Room>>> + '_) {
let (rooms, stream) = self.client.rooms_stream();

let map_room = |room| Room::new(room, &self.sliding_sync);
Expand All @@ -127,9 +127,11 @@ impl RoomList {
)
}

/// Similar to [`Self::entries`] except that it's possible to provide a
/// filter that will filter out room list entries, and that it's also
/// possible to “paginate” over the entries by `page_size`.
/// Get a configurable stream of rooms.
///
/// It's possible to provide a filter that will filter out room list
/// entries, and that it's also possible to “paginate” over the entries by
/// `page_size`. The rooms are also sorted.
///
/// The returned stream will only start yielding diffs once a filter is set
/// through the returned [`RoomListDynamicEntriesController`]. For every
Expand Down

0 comments on commit b74a8c6

Please sign in to comment.