Skip to content

Commit

Permalink
chore(ui): Remove commented code.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Hywan committed Jun 26, 2024
1 parent e59a1fb commit b3f8993
Showing 1 changed file with 9 additions and 60 deletions.
69 changes: 9 additions & 60 deletions crates/matrix-sdk-ui/src/room_list_service/room_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,7 @@ impl RoomList {
self.loading_state.subscribe()
}

/*
/// Get all previous room list entries, in addition to a [`Stream`] to room
/// list entry's updates.
pub fn entries(&self) -> (Vector<R>, impl Stream<Item = Vec<VectorDiff<R>>>) {
self.sliding_sync_list.room_list_stream()
}
*/

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

Expand All @@ -133,67 +126,20 @@ impl RoomList {
)
}

pub fn entries_with_dynamic_adapters(
&self,
page_size: usize,
roominfo_update_recv: broadcast::Receiver<RoomInfoUpdate>,
) -> (impl Stream<Item = Vec<VectorDiff<Room>>> + '_, RoomListDynamicEntriesController) {
let list = self.sliding_sync_list.clone();

let filter_fn_cell = AsyncCell::shared();

let limit = SharedObservable::<usize>::new(page_size);
let limit_stream = limit.subscribe();

let dynamic_entries_controller = RoomListDynamicEntriesController::new(
filter_fn_cell.clone(),
page_size,
limit,
list.maximum_number_of_rooms_stream(),
);

let stream = stream! {
loop {
let filter_fn = filter_fn_cell.take().await;

let (raw_values, raw_stream) = self.entries();

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

let (values, stream) = (raw_values, merged_stream)
.filter(filter_fn)
.sort_by(new_sorter_or(vec![
Box::new(new_sorter_recency()),
Box::new(new_sorter_name())
]))
.dynamic_limit_with_initial_value(page_size, limit_stream.clone());

// Clearing the stream before chaining with the real stream.
yield stream::once(ready(vec![VectorDiff::Reset { values }]))
.chain(stream);
}
}
.switch();

(stream, dynamic_entries_controller)
}

/*
/// 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`.
///
/// The returned stream will only start yielding diffs once a filter is set
/// through the returned [`RoomListDynamicEntriesController`]. For every
/// call to [`RoomListDynamicEntriesController::set_filter`], the stream
/// will yield a [`VectorDiff::Clear`] followed by any updates of the
/// will yield a [`VectorDiff::Reset`] followed by any updates of the
/// room list under that filter (until the next reset).
pub fn entries_with_dynamic_adapters(
&self,
page_size: usize,
roominfo_update_recv: broadcast::Receiver<RoomInfoUpdate>,
) -> (impl Stream<Item = Vec<VectorDiff<R>>>, RoomListDynamicEntriesController) {
) -> (impl Stream<Item = Vec<VectorDiff<Room>>> + '_, RoomListDynamicEntriesController) {
let list = self.sliding_sync_list.clone();

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

let dynamic_entries_controller = RoomListDynamicEntriesController::new(
filter_fn_cell.clone(),
AsyncCell::shared(),
page_size,
limit,
list.maximum_number_of_rooms_stream(),
Expand All @@ -212,13 +157,18 @@ impl RoomList {
let stream = stream! {
loop {
let filter_fn = filter_fn_cell.take().await;
let (raw_values, raw_stream) = list.room_list_stream();

let (raw_values, raw_stream) = self.entries();

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

let (values, stream) = (raw_values, merged_stream)
.filter(filter_fn)
.sort_by(new_sorter_or(vec![
Box::new(new_sorter_recency()),
Box::new(new_sorter_name())
]))
.dynamic_limit_with_initial_value(page_size, limit_stream.clone());

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

(stream, dynamic_entries_controller)
}
*/
}

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

0 comments on commit b3f8993

Please sign in to comment.