From 3e84ddc892f73f4aca954b1dcaf95e37b074b31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 20 Dec 2024 12:09:46 +0100 Subject: [PATCH] fix(ui): Consider banned rooms as rooms we left in the non-left rooms matcher Recently we started to differentiate between rooms we've been banned from from rooms we have left on our own. Sadly the non-left rooms matcher only checked if the room state is not equal to the Left state. This then accidentally moved all the banned rooms to be considered as non-left. We replace the single if expression with a match and list all the states, this way we're going to be notified by the compiler that we need to consider any new states we add in the future. --- .../src/room_list_service/filters/non_left.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs b/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs index 8f59575a787..05ceccd361c 100644 --- a/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs +++ b/crates/matrix-sdk-ui/src/room_list_service/filters/non_left.rs @@ -28,7 +28,10 @@ where F: Fn(&Room) -> RoomState, { fn matches(&self, room: &Room) -> bool { - (self.state)(room) != RoomState::Left + match (self.state)(room) { + RoomState::Joined | RoomState::Invited | RoomState::Knocked => true, + RoomState::Left | RoomState::Banned => false, + } } } @@ -59,6 +62,10 @@ mod tests { let matcher = NonLeftRoomMatcher { state: |_| RoomState::Left }; assert!(!matcher.matches(&room)); + // When a room is in the banned state, it doesn't match either. + let matcher = NonLeftRoomMatcher { state: |_| RoomState::Banned }; + assert!(!matcher.matches(&room)); + // When a room has been joined, it does match (unless it's empty). let matcher = NonLeftRoomMatcher { state: |_| RoomState::Joined }; assert!(matcher.matches(&room));