Skip to content

Commit a820974

Browse files
committed
feat(ui): The RoomList uses sorters!
This patch “installs” the sorters API for the `RoomList`.
1 parent 97692f8 commit a820974

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

crates/matrix-sdk-base/src/sliding_sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl BaseClient {
292292

293293
trace!("ready to submit changes to store");
294294
store.save_changes(&changes).await?;
295-
self.apply_changes(&changes, false);
295+
self.apply_changes(&changes, true);
296296
trace!("applied changes");
297297

298298
// Now that all the rooms information have been saved, update the display name

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ use matrix_sdk::{
2828
use matrix_sdk_base::RoomInfoUpdate;
2929
use tokio::{select, sync::broadcast};
3030

31-
use super::{filters::BoxedFilterFn, Error, Room, State};
31+
use super::{
32+
filters::BoxedFilterFn,
33+
sorters::{new_sorter_name, new_sorter_or, new_sorter_recency},
34+
Error, Room, State,
35+
};
3236

3337
/// A `RoomList` represents a list of rooms, from a
3438
/// [`RoomListService`](super::RoomListService).
@@ -159,6 +163,10 @@ impl RoomList {
159163

160164
let (values, stream) = (raw_values, merged_stream)
161165
.filter(filter_fn)
166+
.sort_by(new_sorter_or(vec![
167+
Box::new(new_sorter_recency()),
168+
Box::new(new_sorter_name())
169+
]))
162170
.dynamic_limit_with_initial_value(page_size, limit_stream.clone());
163171

164172
// Clearing the stream before chaining with the real stream.

0 commit comments

Comments
 (0)