feat(ui): Add the none filter.

It's the opposite of the `all` filter. This one rejects all entries.
This commit is contained in:
Ivan Enderlin
2023-09-21 09:20:28 +02:00
parent 95e8f49afc
commit e91f170589
2 changed files with 27 additions and 0 deletions

View File

@@ -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};

View 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());
}
}