From c860be496931deafa99fc41d6b9bd9cd06f3f78b Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 3 Sep 2025 14:24:08 +0200 Subject: [PATCH] feat(ui): Use the new `latest_event` sorter in the room list. This patch installs the `new_sorter_latest_event` in the room list. --- crates/matrix-sdk-base/src/room/room_info.rs | 2 +- .../matrix-sdk-ui/src/room_list_service/room_list.rs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/matrix-sdk-base/src/room/room_info.rs b/crates/matrix-sdk-base/src/room/room_info.rs index 38b5586c6..f79247e3b 100644 --- a/crates/matrix-sdk-base/src/room/room_info.rs +++ b/crates/matrix-sdk-base/src/room/room_info.rs @@ -1050,7 +1050,7 @@ impl RoomInfo { /// Updates the recency stamp of this room. /// - /// Please read [`Self::recency_stamp`] to learn more. + /// Please read `Self::recency_stamp` to learn more. pub fn update_recency_stamp(&mut self, stamp: u64) { self.recency_stamp = Some(stamp); } 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 d3d4c827b..ae880d533 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 @@ -37,6 +37,7 @@ use super::{ filters::BoxedFilterFn, sorters::{new_sorter_lexicographic, new_sorter_name, new_sorter_recency}, }; +use crate::room_list_service::sorters::new_sorter_latest_event; /// A `RoomList` represents a list of rooms, from a /// [`RoomListService`](super::RoomListService). @@ -165,7 +166,16 @@ impl RoomList { let (values, stream) = (raw_values, merged_streams) .filter(filter_fn) .sort_by(new_sorter_lexicographic(vec![ + // Sort by latest event's kind, i.e. put the rooms with a + // **local** latest event first. + Box::new(new_sorter_latest_event()), + + // Sort rooms by their recency (either by looking + // at their latest event's timestamp, or their + // `recency_stamp`). Box::new(new_sorter_recency()), + + // Finally, sort by name. Box::new(new_sorter_name()) ])) .dynamic_head_with_initial_value(page_size, limit_stream.clone());