Skip to content

Commit d36b68b

Browse files
committed
fix(spaces): have space children with an order field set come before the others in room lists
1 parent 34d71b0 commit d36b68b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,8 @@ impl SpaceRoomList {
371371
.cmp(b_order)
372372
.then(a_state.origin_server_ts.cmp(&b_state.origin_server_ts))
373373
.then(a.room_id.cmp(&b.room_id)),
374-
(Some(_), None) => Ordering::Greater,
375-
(None, Some(_)) => Ordering::Less,
374+
(Some(_), None) => Ordering::Less,
375+
(None, Some(_)) => Ordering::Greater,
376376
(None, None) => a_state
377377
.origin_server_ts
378378
.cmp(&b_state.origin_server_ts)
@@ -850,8 +850,8 @@ mod tests {
850850
Ordering::Less
851851
);
852852

853-
// Finally, when one of the rooms is missing `children_state` data the
854-
// other one should take precedence
853+
// When one of the rooms is missing `children_state` data the other one
854+
// should take precedence
855855
assert_eq!(
856856
SpaceRoomList::compare_rooms(
857857
&make_space_room(owned_room_id!("!Viola:a.b"), None, None, &mut children_state),
@@ -866,6 +866,8 @@ mod tests {
866866
Ordering::Greater
867867
);
868868

869+
// If the `order` is missing from one of the rooms but `children_state`
870+
// is present then the other one should come first
869871
assert_eq!(
870872
SpaceRoomList::compare_rooms(
871873
&make_space_room(
@@ -882,7 +884,7 @@ mod tests {
882884
),
883885
&children_state,
884886
),
885-
Ordering::Less
887+
Ordering::Greater
886888
);
887889
}
888890

@@ -923,9 +925,8 @@ mod tests {
923925
order: Option<&str>,
924926
origin_server_ts: u32,
925927
) -> HierarchySpaceChildEvent {
926-
let json = json!({
928+
let mut json = json!({
927929
"content": {
928-
"order": order.unwrap_or(""),
929930
"via": []
930931
},
931932
"origin_server_ts": origin_server_ts,
@@ -934,6 +935,10 @@ mod tests {
934935
"type": "m.space.child"
935936
});
936937

938+
if let Some(order) = order {
939+
json["content"]["order"] = json!(order);
940+
}
941+
937942
from_value::<HierarchySpaceChildEvent>(json).unwrap()
938943
}
939944
}

0 commit comments

Comments
 (0)