Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ui,ffi): Remove the RoomList::entries method (reapply #3999) #4083

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions crates/matrix-sdk-ui/src/room_list_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
//! fluid user experience for a Matrix client.
//!
//! [`RoomListService::all_rooms`] provides a way to get a [`RoomList`] for all
//! the rooms. From that, calling [`RoomList::entries`] provides a way to get a
//! stream of room list entry. This stream can be filtered, and the filter can
//! be changed over time.
//! the rooms. From that, calling [`RoomList::entries_with_dynamic_adapters`]
//! provides a way to get a stream of rooms. This stream is sorted, can be
//! filtered, and the filter can be changed over time.
//!
//! [`RoomListService::state`] provides a way to get a stream of the state
//! machine's state, which can be pretty helpful for the client app.
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 @@ -118,8 +118,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 @@ -130,9 +130,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
92 changes: 0 additions & 92 deletions crates/matrix-sdk-ui/tests/integration/room_list_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,98 +1196,6 @@ async fn test_loading_states() -> Result<(), Error> {
Ok(())
}

#[async_test]
async fn test_entries_stream() -> Result<(), Error> {
let (_, server, room_list) = new_room_list_service().await?;

let sync = room_list.sync();
pin_mut!(sync);

let all_rooms = room_list.all_rooms().await?;

let (previous_entries, entries_stream) = all_rooms.entries();
pin_mut!(entries_stream);

sync_then_assert_request_and_fake_response! {
[server, room_list, sync]
states = Init => SettingUp,
assert request >= {
"lists": {
ALL_ROOMS: {
"ranges": [[0, 19]],
"timeline_limit": 1,
},
},
},
respond with = {
"pos": "0",
"lists": {
ALL_ROOMS: {
"count": 10,
},
},
"rooms": {
"!r0:bar.org": {
"initial": true,
"timeline": [],
},
"!r1:bar.org": {
"initial": true,
"timeline": [],
},
"!r2:bar.org": {
"initial": true,
"timeline": [],
},
},
},
};

assert!(previous_entries.is_empty());
assert_entries_batch! {
[entries_stream]
push back [ "!r0:bar.org" ];
push back [ "!r1:bar.org" ];
push back [ "!r2:bar.org" ];
end;
};

sync_then_assert_request_and_fake_response! {
[server, room_list, sync]
states = SettingUp => Running,
assert request >= {
"lists": {
ALL_ROOMS: {
"ranges": [[0, 9]],
"timeline_limit": 0,
},
},
},
respond with = {
"pos": "1",
"lists": {
ALL_ROOMS: {
"count": 9,
},
},
"rooms": {
"!r3:bar.org": {
"initial": true,
"timeline": [],
},
},
},
};

assert_entries_batch! {
[entries_stream]
push back [ "!r3:bar.org" ];
end;
};

Ok(())
}

#[async_test]
async fn test_dynamic_entries_stream() -> Result<(), Error> {
let (client, server, room_list) = new_room_list_service().await?;
Expand Down
Loading