From 781d1703eae4f9f8f64c02fd3187bb70af5d8db3 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 26 Jun 2024 16:38:53 +0200 Subject: [PATCH] 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. --- .../src/room_list_service/room_list.rs | 69 +++---------------- 1 file changed, 9 insertions(+), 60 deletions(-) diff --git a/crates/matrix-sdk-ui/src/room_list_service/room_list.rs b/crates/matrix-sdk-ui/src/room_list_service/room_list.rs index f8e38d68c01..06322f58c93 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/room_list.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/room_list.rs @@ -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, impl Stream>>) { - self.sliding_sync_list.room_list_stream() - } - */ - + /// Get all previous rooms, in addition to a [`Stream`] to rooms' updates. pub fn entries(&self) -> (Vector, impl Stream>> + '_) { let (rooms, stream) = self.client.rooms_stream(); @@ -133,53 +126,6 @@ impl RoomList { ) } - pub fn entries_with_dynamic_adapters( - &self, - page_size: usize, - roominfo_update_recv: broadcast::Receiver, - ) -> (impl Stream>> + '_, RoomListDynamicEntriesController) { - let list = self.sliding_sync_list.clone(); - - let filter_fn_cell = AsyncCell::shared(); - - let limit = SharedObservable::::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`. @@ -187,13 +133,13 @@ impl RoomList { /// 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, - ) -> (impl Stream>>, RoomListDynamicEntriesController) { + ) -> (impl Stream>> + '_, RoomListDynamicEntriesController) { let list = self.sliding_sync_list.clone(); let filter_fn_cell = AsyncCell::shared(); @@ -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(), @@ -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. @@ -230,7 +180,6 @@ impl RoomList { (stream, dynamic_entries_controller) } - */ } /// This function remembers the current state of the unfiltered room list, so it