Skip to content

Commit b3f8993

Browse files
committed
chore(ui): Remove commented code.
The patch looks a bit weird because the commented code that is removed was similar to an existing code close to it. But what this patch does it purely removing commented code and adding missing doc.
1 parent e59a1fb commit b3f8993

File tree

1 file changed

+9
-60
lines changed

1 file changed

+9
-60
lines changed

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

Lines changed: 9 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,7 @@ impl RoomList {
114114
self.loading_state.subscribe()
115115
}
116116

117-
/*
118-
/// Get all previous room list entries, in addition to a [`Stream`] to room
119-
/// list entry's updates.
120-
pub fn entries(&self) -> (Vector<R>, impl Stream<Item = Vec<VectorDiff<R>>>) {
121-
self.sliding_sync_list.room_list_stream()
122-
}
123-
*/
124-
117+
/// Get all previous rooms, in addition to a [`Stream`] to rooms' updates.
125118
pub fn entries(&self) -> (Vector<Room>, impl Stream<Item = Vec<VectorDiff<Room>>> + '_) {
126119
let (rooms, stream) = self.client.rooms_stream();
127120

@@ -133,67 +126,20 @@ impl RoomList {
133126
)
134127
}
135128

136-
pub fn entries_with_dynamic_adapters(
137-
&self,
138-
page_size: usize,
139-
roominfo_update_recv: broadcast::Receiver<RoomInfoUpdate>,
140-
) -> (impl Stream<Item = Vec<VectorDiff<Room>>> + '_, RoomListDynamicEntriesController) {
141-
let list = self.sliding_sync_list.clone();
142-
143-
let filter_fn_cell = AsyncCell::shared();
144-
145-
let limit = SharedObservable::<usize>::new(page_size);
146-
let limit_stream = limit.subscribe();
147-
148-
let dynamic_entries_controller = RoomListDynamicEntriesController::new(
149-
filter_fn_cell.clone(),
150-
page_size,
151-
limit,
152-
list.maximum_number_of_rooms_stream(),
153-
);
154-
155-
let stream = stream! {
156-
loop {
157-
let filter_fn = filter_fn_cell.take().await;
158-
159-
let (raw_values, raw_stream) = self.entries();
160-
161-
// Combine normal stream events with other updates from rooms
162-
let merged_stream = merge_stream_and_receiver(raw_values.clone(), raw_stream, roominfo_update_recv.resubscribe());
163-
164-
let (values, stream) = (raw_values, merged_stream)
165-
.filter(filter_fn)
166-
.sort_by(new_sorter_or(vec![
167-
Box::new(new_sorter_recency()),
168-
Box::new(new_sorter_name())
169-
]))
170-
.dynamic_limit_with_initial_value(page_size, limit_stream.clone());
171-
172-
// Clearing the stream before chaining with the real stream.
173-
yield stream::once(ready(vec![VectorDiff::Reset { values }]))
174-
.chain(stream);
175-
}
176-
}
177-
.switch();
178-
179-
(stream, dynamic_entries_controller)
180-
}
181-
182-
/*
183129
/// Similar to [`Self::entries`] except that it's possible to provide a
184130
/// filter that will filter out room list entries, and that it's also
185131
/// possible to “paginate” over the entries by `page_size`.
186132
///
187133
/// The returned stream will only start yielding diffs once a filter is set
188134
/// through the returned [`RoomListDynamicEntriesController`]. For every
189135
/// call to [`RoomListDynamicEntriesController::set_filter`], the stream
190-
/// will yield a [`VectorDiff::Clear`] followed by any updates of the
136+
/// will yield a [`VectorDiff::Reset`] followed by any updates of the
191137
/// room list under that filter (until the next reset).
192138
pub fn entries_with_dynamic_adapters(
193139
&self,
194140
page_size: usize,
195141
roominfo_update_recv: broadcast::Receiver<RoomInfoUpdate>,
196-
) -> (impl Stream<Item = Vec<VectorDiff<R>>>, RoomListDynamicEntriesController) {
142+
) -> (impl Stream<Item = Vec<VectorDiff<Room>>> + '_, RoomListDynamicEntriesController) {
197143
let list = self.sliding_sync_list.clone();
198144

199145
let filter_fn_cell = AsyncCell::shared();
@@ -203,7 +149,6 @@ impl RoomList {
203149

204150
let dynamic_entries_controller = RoomListDynamicEntriesController::new(
205151
filter_fn_cell.clone(),
206-
AsyncCell::shared(),
207152
page_size,
208153
limit,
209154
list.maximum_number_of_rooms_stream(),
@@ -212,13 +157,18 @@ impl RoomList {
212157
let stream = stream! {
213158
loop {
214159
let filter_fn = filter_fn_cell.take().await;
215-
let (raw_values, raw_stream) = list.room_list_stream();
160+
161+
let (raw_values, raw_stream) = self.entries();
216162

217163
// Combine normal stream events with other updates from rooms
218164
let merged_stream = merge_stream_and_receiver(raw_values.clone(), raw_stream, roominfo_update_recv.resubscribe());
219165

220166
let (values, stream) = (raw_values, merged_stream)
221167
.filter(filter_fn)
168+
.sort_by(new_sorter_or(vec![
169+
Box::new(new_sorter_recency()),
170+
Box::new(new_sorter_name())
171+
]))
222172
.dynamic_limit_with_initial_value(page_size, limit_stream.clone());
223173

224174
// Clearing the stream before chaining with the real stream.
@@ -230,7 +180,6 @@ impl RoomList {
230180

231181
(stream, dynamic_entries_controller)
232182
}
233-
*/
234183
}
235184

236185
/// This function remembers the current state of the unfiltered room list, so it

0 commit comments

Comments
 (0)