@@ -114,14 +114,7 @@ impl RoomList {
114
114
self . loading_state . subscribe ( )
115
115
}
116
116
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.
125
118
pub fn entries ( & self ) -> ( Vector < Room > , impl Stream < Item = Vec < VectorDiff < Room > > > + ' _ ) {
126
119
let ( rooms, stream) = self . client . rooms_stream ( ) ;
127
120
@@ -133,67 +126,20 @@ impl RoomList {
133
126
)
134
127
}
135
128
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
- /*
183
129
/// Similar to [`Self::entries`] except that it's possible to provide a
184
130
/// filter that will filter out room list entries, and that it's also
185
131
/// possible to “paginate” over the entries by `page_size`.
186
132
///
187
133
/// The returned stream will only start yielding diffs once a filter is set
188
134
/// through the returned [`RoomListDynamicEntriesController`]. For every
189
135
/// 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
191
137
/// room list under that filter (until the next reset).
192
138
pub fn entries_with_dynamic_adapters (
193
139
& self ,
194
140
page_size : usize ,
195
141
roominfo_update_recv : broadcast:: Receiver < RoomInfoUpdate > ,
196
- ) -> (impl Stream<Item = Vec<VectorDiff<R >>>, RoomListDynamicEntriesController) {
142
+ ) -> ( impl Stream < Item = Vec < VectorDiff < Room > > > + ' _ , RoomListDynamicEntriesController ) {
197
143
let list = self . sliding_sync_list . clone ( ) ;
198
144
199
145
let filter_fn_cell = AsyncCell :: shared ( ) ;
@@ -203,7 +149,6 @@ impl RoomList {
203
149
204
150
let dynamic_entries_controller = RoomListDynamicEntriesController :: new (
205
151
filter_fn_cell. clone ( ) ,
206
- AsyncCell::shared(),
207
152
page_size,
208
153
limit,
209
154
list. maximum_number_of_rooms_stream ( ) ,
@@ -212,13 +157,18 @@ impl RoomList {
212
157
let stream = stream ! {
213
158
loop {
214
159
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( ) ;
216
162
217
163
// Combine normal stream events with other updates from rooms
218
164
let merged_stream = merge_stream_and_receiver( raw_values. clone( ) , raw_stream, roominfo_update_recv. resubscribe( ) ) ;
219
165
220
166
let ( values, stream) = ( raw_values, merged_stream)
221
167
. filter( filter_fn)
168
+ . sort_by( new_sorter_or( vec![
169
+ Box :: new( new_sorter_recency( ) ) ,
170
+ Box :: new( new_sorter_name( ) )
171
+ ] ) )
222
172
. dynamic_limit_with_initial_value( page_size, limit_stream. clone( ) ) ;
223
173
224
174
// Clearing the stream before chaining with the real stream.
@@ -230,7 +180,6 @@ impl RoomList {
230
180
231
181
( stream, dynamic_entries_controller)
232
182
}
233
- */
234
183
}
235
184
236
185
/// This function remembers the current state of the unfiltered room list, so it
0 commit comments