feat(ui): Implement the “fuzzy match room name” filter #2335
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Address #1911.
This patch implements a new pre-defined filter for room list entries:
room_list_service::filters::fuzzy_match_room_name
.The idea is that all filters can be build via a
new_filter
function, which produces a closureFn(&RoomListEntry) -> bool + Send + Sync + 'static
.For
fuzzy_match_room_name
, I'm usingfuzzy_matcher
from theskim
project. It's battle-tested and widely used viaskim
. However, it works onchar
, and no Unicode transformations are applied. So, looking for stf won't match Ștefan —even with smart case/ignore case— for instance, because S is different from Ș.So before matching the pattern over the subject, we apply some transformations. I wanted to do some transliteration + normalization.
Ideally, I wanted to use
icu4x
. The transliteration API isn't implemented yet, so I'll just use the normalization API. However, those dependencies can be quite heavy. Looking inside our dependencies, we see thaturl
is usingidna
, which usesunicode-normalization
, it's a project from @unicode-rs, not from @unicode-org.unicode-normalization
is slower thanicu4x
but it's already in our tree of deps, so let's use it. Let's measure and see if speed could be a problem here.This patch then adds a
filters::normalize_string
to run some transformations (NFD + filter out combining marks).Let's see if this approach suits for most common needs for all languages and cultures.
This patch doesn't implement the bindings for
entries_filtered
to FFI yet, it will be done in another PR.