Skip to content

Commit eab6c0c

Browse files
committed
Filter out the current parent space from the /hierarchy and SpaceRoomList responses.
1 parent 9837bd4 commit eab6c0c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

crates/matrix-sdk-ui/src/spaces/room_list.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl SpaceServiceRoomList {
131131
self.pagination_state.set(SpaceServiceRoomListPaginationState::Loading);
132132

133133
let mut request = get_hierarchy::v1::Request::new(self.parent_space_id.clone());
134-
request.max_depth = Some(uint!(1));
134+
request.max_depth = Some(uint!(1)); // We only want the immediate children of the space
135135

136136
if let PaginationToken::HasMore(ref token) = *self.token.lock().unwrap() {
137137
request.from = Some(token.clone());
@@ -155,15 +155,16 @@ impl SpaceServiceRoomList {
155155
result
156156
.rooms
157157
.iter()
158-
.map(|room| {
159-
(
160-
&room.summary,
161-
self.client.get_room(&room.summary.room_id),
162-
room.children_state.len(),
163-
)
164-
})
165-
.map(|(summary, room, children_count)| {
166-
SpaceServiceRoom::new_from_summary(summary, room, children_count as u64)
158+
.flat_map(|room| {
159+
if room.summary.room_id == self.parent_space_id {
160+
None
161+
} else {
162+
Some(SpaceServiceRoom::new_from_summary(
163+
&room.summary,
164+
self.client.get_room(&room.summary.room_id),
165+
room.children_state.len() as u64,
166+
))
167+
}
167168
})
168169
.collect::<Vec<_>>(),
169170
);
@@ -238,7 +239,7 @@ mod tests {
238239
// Paginating the room list
239240
server
240241
.mock_get_hierarchy()
241-
.ok_with_room_ids(vec![child_space_id_1, child_space_id_2])
242+
.ok_with_room_ids(vec![parent_space_id, child_space_id_1, child_space_id_2])
242243
.mount()
243244
.await;
244245

0 commit comments

Comments
 (0)