mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-08 07:56:55 -04:00
feat(ui): The RoomList uses sorters!
This patch “installs” the sorters API for the `RoomList`.
This commit is contained in:
@@ -292,7 +292,12 @@ impl BaseClient {
|
||||
|
||||
trace!("ready to submit changes to store");
|
||||
store.save_changes(&changes).await?;
|
||||
self.apply_changes(&changes, false);
|
||||
self.apply_changes(
|
||||
&changes,
|
||||
// The changes may result in a latest event update, which should trigger a room list
|
||||
// re-ordering. This the room list should be notified by these changes.
|
||||
true,
|
||||
);
|
||||
trace!("applied changes");
|
||||
|
||||
// Now that all the rooms information have been saved, update the display name
|
||||
|
||||
@@ -28,7 +28,11 @@ use matrix_sdk::{
|
||||
use matrix_sdk_base::RoomInfoUpdate;
|
||||
use tokio::{select, sync::broadcast};
|
||||
|
||||
use super::{filters::BoxedFilterFn, Error, Room, State};
|
||||
use super::{
|
||||
filters::BoxedFilterFn,
|
||||
sorters::{new_sorter_name, new_sorter_or, new_sorter_recency},
|
||||
Error, Room, State,
|
||||
};
|
||||
|
||||
/// A `RoomList` represents a list of rooms, from a
|
||||
/// [`RoomListService`](super::RoomListService).
|
||||
@@ -161,6 +165,10 @@ impl RoomList {
|
||||
|
||||
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.
|
||||
@@ -196,7 +204,7 @@ fn merge_stream_and_receiver(
|
||||
|
||||
// Search list for the updated room
|
||||
for (index, room) in raw_current_values.iter().enumerate() {
|
||||
if room.room_id() == &update.room_id {
|
||||
if room.room_id() == update.room_id {
|
||||
let update = VectorDiff::Set { index, value: raw_current_values[index].clone() };
|
||||
yield vec![update];
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user