Skip to content

Commit

Permalink
fix(ui): Consider banned rooms as rooms we left in the non-left rooms…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
poljar authored Dec 20, 2024
1 parent f8a9d12 commit 36427b0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions crates/matrix-sdk-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ All notable changes to this project will be documented in this file.

## [Unreleased] - ReleaseDate

### Bug Fixes

- Don't consider rooms in the banned state to be non-left rooms. This bug was
introduced due to the introduction of the banned state for rooms, and the
non-left room filter did not take the new room stat into account.
([#4448](https://github.com/matrix-org/matrix-rust-sdk/pull/4448))

## [0.9.0] - 2024-12-18

### Bug Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}

Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 36427b0

Please sign in to comment.