-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ui): Implement RoomList::entries_with_dynamic_filter
#2392
feat(ui): Implement RoomList::entries_with_dynamic_filter
#2392
Conversation
Because it makes more sense.
This patch updates the tests to ensure `entries_with_dynamic_filter` works as expected.
These test cases are more easy to understand than the previous one if you ask me.
First, this patch makes `RoomList::entries` infallible. Second, this patch implements `RoomList::entries_with_dynamic_filter`.
This patch implements a new `all` filter.
This patch removes `RoomListEntriesDynamicFilter::set_with_fuzzy_match_pattern` and replaces it by a single `::set` method. It takes a new enum as parameter: `RoomListEntriesDynamicFilterKind`. This enum has a `FuzzyMatchRoomName` variant to simulate the removed method. It also adds the `All` variant, to represent the `all` filter.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #2392 +/- ##
==========================================
+ Coverage 77.78% 77.79% +0.01%
==========================================
Files 175 176 +1
Lines 18619 18643 +24
==========================================
+ Hits 14482 14504 +22
- Misses 4137 4139 +2
☔ View full report in Codecov by Sentry. |
/// Create a new filter that will accept all filled or invalidated entries. | ||
pub fn new_filter() -> impl Fn(&RoomListEntry) -> bool { | ||
|room_list_entry| -> bool { | ||
matches!(room_list_entry, RoomListEntry::Filled(_) | RoomListEntry::Invalidated(_)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it weird that this filter is called "all" but still excludes some entries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that’s a technical details. Empty
are always filtered out because they are never rendered.
Address #1911.
Thanks for @jplatte for his collaboration on this patch.
This patch can be reviewed commit-by-commit, but a one-diff review is also doable I guess.
On FFI side:
RoomList::entries
is now infallible,RoomList::entries_with_dynamic_filter
has been implemented. It returns a stream + aRoomListDynamicFilter
object, which has a single method:set
. It acceptsRoomListDynamicFilterKind
value, which is an enum withAll
orFuzzyMatchRoomName
variants.Why this design? Because it allows the client-app to use
entries
if it provides a single “static” room list, orentries_with_dynamic_filter
if it considers to filter the list with various filters. The client-app doesn't have to callentries
orentries_with_dynamic_filter
alternatively, it can just switch betweenAll
or other variants depending of the filters.On the Rust side:
all
filter, which returnstrue
for allRoomListEntry
that areFilled
orInvalidated
,RoomList::entries_with_dynamic_filter
method,RoomList::entries_filtered
method to::entries_with_static_filter
.