feat(natural language): make natural language prefixes configurable #795
No reviewers
Labels
No Label
area/internal-code
changes requested
confirmed
dependencies
duplicate
good first issue
help wanted
hosting
invalid
kind/bug
kind/feature
question
wontfix
No Milestone
No project
No Assignees
2 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vikunja/frontend#795
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/natural-language-config"
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 PR adds a user setting to make the natural language prefixes configurable. It also adds a new mode "Vikunja" that should feel more intuitive and is different from the current mode which was basically a 1:1 copy of Todoist's prefixes. The new "Vikunja" mode is now the default.
Additionally, it adds a disable option to disable parsing completely.
@dpschen Would you mind taking a look at this?
Will do this evening :)
4d09532fd7
tod30a1e4083
@ -76,3 +79,4 @@
data() {
return {
visible: false,
available: getQuickAddMagicMode() !== 'disabled',
mode
should be read out in data once. So that it doesn't has to be repeated – saving one access to localStorage.Done!
@ -77,2 +80,4 @@
return {
visible: false,
available: getQuickAddMagicMode() !== 'disabled',
prefixes: {},
..Then prefixes could be a computed.
Done!
@ -0,0 +2,4 @@
const key = 'quickAddMagicMode'
export const setQuickAddMagicMode = (mode: string) => {
Since this basically already is an abstraction around localStorage, how about going the full way and create it already?
This way we can use this in the future everywhere where localStorage is used.
Yes, I'd like to do this but there's more things which need migration. An abstraction would ideally be used everywhere there currently is an access to localStorage and also handle things like cleanup on logout and such in one central place. That's on the radar but out of scope for this PR IMHO.
Makes sense 👍
@ -0,0 +7,4 @@
}
export const getQuickAddMagicMode = (): PrefixMode => {
return localStorage.getItem(key) ?? PrefixMode.Todoist
The default prefix should be defined together with the other prefixes.
Done, renamed the
Vikunja
one.@ -6,2 +4,2 @@
const PRIORITY_PREFIX: string = '!'
const ASSIGNEE_PREFIX: string = '+'
export const VIKUNJA_PREFIXES: Prefixes = {
label: '~',
Writing
~
needs two keys on a mac with german keyboard. How about*
?Or does the tilde have an origin that I'm not aware of?
The tilde doesn't have a special meaning. I think it makes sense have something easily reachable, changed to
*
.@ -45,0 +67,4 @@
return result
}
let prefixes: Prefixes = TODOIST_PREFIXES
Maybe it's possible to define the prefixes as object so that they can be referenced similar to this:
If
prefixId === undefined
it would be equal to disabled.In case you know the one you want to reference you could still do that:
Done that, but kept an explicit option for disabled so that we can return it in the
getQuickAddMagicMode
method.@ -80,0 +84,4 @@
</span>
<div class="select ml-2">
<select v-model="quickAddMagicMode">
<option value="disabled">{{ $t('user.settings.quickAddMagic.disabled') }}</option>
The list of possible options could be automatically created by the available prefixes.
That way the prefixes are just defined at one place.
Also: is disabled an option that should even be available?
Maybe it's fine already to chose between the different sets.
I think there should be an option to disable it. Ideally there would not be a need for it, but until the natural language parsing is perfect (it will never be), there should be an option to disable it in cases where it generates a lot of false positives 🙂
Oh yes that makes sense! Didn't think about that.
@ -0,0 +9,4 @@
export const getQuickAddMagicMode = (): PrefixMode => {
const mode = localStorage.getItem(key)
switch (mode) {
Would make it future proof by supporting more modes by default.
That's a nice simplification. Added 👍
Actually, this always disabled quick add magic, no matter the value of
mode
- reverted this in4a1b402e62
.Not sure why this was happening, I guess it had something to do with the way typescript enums work.
Makes sense! It was pseudocode from memory. Should have been: