Skip to content

Commit c6dc070

Browse files
pixlwavestefanceriu
authored andcommitted
chore: Refactor non_space.rs filter to space.rs, using new_filter_not in the FFI.
1 parent 486befc commit c6dc070

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

bindings/matrix-sdk-ffi/src/room_list.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use matrix_sdk_ui::{
1616
room_list_service::filters::{
1717
new_filter_all, new_filter_any, new_filter_category, new_filter_deduplicate_versions,
1818
new_filter_favourite, new_filter_fuzzy_match_room_name, new_filter_invite,
19-
new_filter_joined, new_filter_low_priority, new_filter_non_left, new_filter_non_space,
20-
new_filter_none, new_filter_normalized_match_room_name, new_filter_not, new_filter_unread,
19+
new_filter_joined, new_filter_low_priority, new_filter_non_left, new_filter_none,
20+
new_filter_normalized_match_room_name, new_filter_not, new_filter_space, new_filter_unread,
2121
BoxedFilterFn, RoomCategory,
2222
},
2323
unable_to_decrypt_hook::UtdHookManager,
@@ -499,7 +499,7 @@ impl From<RoomListEntriesDynamicFilterKind> for BoxedFilterFn {
499499
filters.into_iter().map(|filter| BoxedFilterFn::from(filter)).collect(),
500500
)),
501501
Kind::NonLeft => Box::new(new_filter_non_left()),
502-
Kind::NonSpace => Box::new(new_filter_non_space()),
502+
Kind::NonSpace => Box::new(new_filter_not(Box::new(new_filter_space()))),
503503
Kind::Joined => Box::new(new_filter_joined()),
504504
Kind::Unread => Box::new(new_filter_unread()),
505505
Kind::Favourite => Box::new(new_filter_favourite()),

crates/matrix-sdk-ui/src/room_list_service/filters/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ mod invite;
6161
mod joined;
6262
mod low_priority;
6363
mod non_left;
64-
mod non_space;
6564
mod none;
6665
mod normalized_match_room_name;
6766
mod not;
67+
mod space;
6868
mod unread;
6969

7070
pub use all::new_filter as new_filter_all;
@@ -82,12 +82,12 @@ use matrix_sdk::Room;
8282
#[cfg(test)]
8383
use matrix_sdk_test::{JoinedRoomBuilder, SyncResponseBuilder};
8484
pub use non_left::new_filter as new_filter_non_left;
85-
pub use non_space::new_filter as new_filter_non_space;
8685
pub use none::new_filter as new_filter_none;
8786
pub use normalized_match_room_name::new_filter as new_filter_normalized_match_room_name;
8887
pub use not::new_filter as new_filter_not;
8988
#[cfg(test)]
9089
use ruma::RoomId;
90+
pub use space::new_filter as new_filter_space;
9191
use unicode_normalization::{UnicodeNormalization, char::is_combining_mark};
9292
pub use unread::new_filter as new_filter_unread;
9393
#[cfg(test)]

crates/matrix-sdk-ui/src/room_list_service/filters/non_space.rs renamed to crates/matrix-sdk-ui/src/room_list_service/filters/space.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,26 @@
1414

1515
use super::{super::Room, Filter};
1616

17-
struct NonSpaceRoomMatcher<F>
17+
struct SpaceRoomMatcher<F>
1818
where
1919
F: Fn(&Room) -> bool,
2020
{
21-
is_not_space: F,
21+
is_space: F,
2222
}
2323

24-
impl<F> NonSpaceRoomMatcher<F>
24+
impl<F> SpaceRoomMatcher<F>
2525
where
2626
F: Fn(&Room) -> bool,
2727
{
2828
fn matches(&self, room: &Room) -> bool {
29-
(self.is_not_space)(room)
29+
(self.is_space)(room)
3030
}
3131
}
3232

33-
/// Create a new filter that will filter out rooms that are not spaces, i.e.
33+
/// Create a new filter that will filter out rooms that are spaces, i.e.
3434
/// room with a `room_type` of `m.space` as defined in <https://spec.matrix.org/latest/client-server-api/#spaces>
3535
pub fn new_filter() -> impl Filter {
36-
let matcher = NonSpaceRoomMatcher { is_not_space: move |room| !room.is_space() };
36+
let matcher = SpaceRoomMatcher { is_space: move |room| room.is_space() };
3737

3838
move |room| -> bool { matcher.matches(room) }
3939
}
@@ -47,14 +47,14 @@ mod tests {
4747
use super::{super::new_rooms, *};
4848

4949
#[async_test]
50-
async fn test_not_space() {
50+
async fn test_space() {
5151
let (client, server) = logged_in_client_with_server().await;
5252
let [room] = new_rooms([room_id!("!a:b.c")], &client, &server).await;
5353

54-
let matcher = NonSpaceRoomMatcher { is_not_space: |_| false };
54+
let matcher = SpaceRoomMatcher { is_space: |_| false };
5555
assert!(!matcher.matches(&room));
5656

57-
let matcher = NonSpaceRoomMatcher { is_not_space: |_| true };
57+
let matcher = SpaceRoomMatcher { is_space: |_| true };
5858
assert!(matcher.matches(&room));
5959
}
6060
}

0 commit comments

Comments
 (0)