WIP: Add regex filter support #427
No reviewers
Labels
No labels
a11y
Bug
Bug fix
Critical Priority
Documentation
Feature
Feature request
Held for next release cycle
High Priority
Low Priority
Medium Priority
Minor change
Translation/Locale
WIP
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: AkkomaGang/akkoma-fe#427
Loading…
Reference in a new issue
No description provided.
Delete branch "norm/pleroma-fe:regex-mute-filter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This makes any filter that starts and ends in forward slashes act as a
regex filter instead of a simple substring filter.
Currently doesn't support trailing flags unlike actual JS regexes, so
modifiers should be used instead for that functionality:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Modifier
Fixes #273
Noticed one comment in #273 suggests using the
~r/regex/
syntax instead. Don't mind either way, so I'd like thoughts on the syntax or if there should be some other way to denote a regex based filter.I don’t really mind either syntax, but perhaps one point in favour of
~r/
is it allows trailing flags while still being neraly unabigously intended as a regex just from the front partSince non-regex mutes are case-insensitive and it’s possible to reënable case sensitivity via modifier, i think it makes sense to let regexes ignore case by default too
Finally, and this will be a bit more effort, recreating regexes for each post is probably not a good idea. It would be good to pre-compile them just once when settings are loaded or the mute list updated
One thing I'm having trouble with trying to solve is whether I should keep the raw value of the regexes/words in the config or convert from the parsed version when loading the settings tab.
Just storing the regexes in the
muteWords
store causes them to apprear like/this/i
instead of~r/this/
when reopening settings.Since settings are synced to/from the server, i think it’s best for the setting itself to remain as the original textual representation and the parsed version stored outside the synced settings
Add regex filter supportto WIP: Add regex filter supportWhere would be a good place to have a global store of things to not get synced to the server?
I looked at how the frontend handles stores again and:
$store.mergedConfig
is passed to the server on Sync, here nothing precompiled can occur.mergedConfig
are set bysetOption
dispatches inside the settings modulesetdisplayBackground
dispatch to the users store, you can look at #371Regexes need to recompiled at least after either new/iniital settings are received from the serve, or the setting was edited in the filtering tab. The current code doesn't account for the former.
To avoid spreading recompile actions over seeral places, it might be best to add a new
compiledMuteWords
value to the store associated with the status parser. If it’s already set this isused directly, otherwisemuteWordHits
can compile the config value and cache it tocompiledMuteWords
.Then a cache invalidation step can be added to the
setOption
implementation though i don't know Vue well enough to immediately know whether dispatches work cross-modules/substores or how to otherwise communicate the need for recompile to the status parser (i.e. either setting the compiled version back toundefined
or toggling a separate dirty flag)View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.