diff --git a/crates/matrix-sdk-ui/src/room_list_service/sorters/name.rs b/crates/matrix-sdk-ui/src/room_list_service/sorters/name.rs index 41616108c74..227d56d1b66 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/sorters/name.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/sorters/name.rs @@ -28,6 +28,10 @@ where F: Fn(&Room, &Room) -> (Option, Option), { fn matches(&self, left: &Room, right: &Room) -> Ordering { + if left.id() == right.id() { + return Ordering::Greater; + } + let (left_name, right_name) = (self.names)(left, right); left_name.cmp(&right_name) diff --git a/crates/matrix-sdk-ui/src/room_list_service/sorters/recency.rs b/crates/matrix-sdk-ui/src/room_list_service/sorters/recency.rs index 215275a975c..077a49ec170 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/sorters/recency.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/sorters/recency.rs @@ -30,6 +30,11 @@ where F: Fn(&Room, &Room) -> (Option, Option), { fn matches(&self, left: &Room, right: &Room) -> Ordering { + // `left` and `right` are the same room. + if left.id() == right.id() { + return Ordering::Greater; + } + match (self.latest_events)(left, right) { (Some(left_latest_event), Some(right_latest_event)) => left_latest_event .event_origin_server_ts()