mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-19 14:19:06 -04:00
feat(ui): Add the none filter.
It's the opposite of the `all` filter. This one rejects all entries.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
mod all;
|
||||
mod fuzzy_match_room_name;
|
||||
mod none;
|
||||
mod normalized_match_room_name;
|
||||
|
||||
pub use all::new_filter as new_filter_all;
|
||||
pub use fuzzy_match_room_name::new_filter as new_filter_fuzzy_match_room_name;
|
||||
pub use none::new_filter as new_filter_none;
|
||||
pub use normalized_match_room_name::new_filter as new_filter_normalized_match_room_name;
|
||||
use unicode_normalization::{char::is_combining_mark, UnicodeNormalization};
|
||||
|
||||
|
||||
25
crates/matrix-sdk-ui/src/room_list_service/filters/none.rs
Normal file
25
crates/matrix-sdk-ui/src/room_list_service/filters/none.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use matrix_sdk::RoomListEntry;
|
||||
|
||||
/// Create a new filter that will reject all entries.
|
||||
pub fn new_filter() -> impl Fn(&RoomListEntry) -> bool {
|
||||
|_room_list_entry| -> bool { false }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::ops::Not;
|
||||
|
||||
use matrix_sdk::RoomListEntry;
|
||||
use ruma::room_id;
|
||||
|
||||
use super::new_filter;
|
||||
|
||||
#[test]
|
||||
fn test_all_kind_of_room_list_entry() {
|
||||
let none = new_filter();
|
||||
|
||||
assert!(none(&RoomListEntry::Empty).not());
|
||||
assert!(none(&RoomListEntry::Filled(room_id!("!r0:bar.org").to_owned())).not());
|
||||
assert!(none(&RoomListEntry::Invalidated(room_id!("!r0:bar.org").to_owned())).not());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user