fix: setting background to state mutation violation #858
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#858
Loading…
Reference in New Issue
No description provided.
Delete Branch "fix/list-background-vuex"
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?
State mutations must be synchronous. Using a promise.then handler to set the background is a violation of that.
@ -87,3 +87,3 @@
this.$route.name === 'namespaces.index'
) {
this.$store.commit(CURRENT_LIST, null)
this.$store.dispatch(CURRENT_LIST, null)
return the result => make async
You mean the whole action?
Yes. Same reason as in the other answer below.
Done
@ -65,0 +85,4 @@
},
},
actions: {
[CURRENT_LIST](ctx, currentList) {
With
[CURRENT_LIST]({state}, currentList)
we could keep the diff smaller. But not sure if that makes senseI think it does make sense, changed it.
@ -98,4 +122,4 @@
) {
if (currentList.backgroundInformation) {
const listService = new ListService()
listService.background(currentList)
Not that this is an action maybe we can already use await here.
Done
@ -143,3 +143,3 @@
.then(r => {
this.$store.commit(CURRENT_LIST, r)
this.$store.dispatch(CURRENT_LIST, r)
this.setTitle(this.getListTitle(r))
Really not sure here: should the setTitle await for the action to finish?
I think not. Basically, all that the action does that is async is loading the background. The rest are mutations which happen almost immedieatly (from the user's perspective anyway). I think if the list itself already loaded it is rather confusing if it is waiting for no other reason than to load the list background. Especially since I plan to use BlurHash in the future for list backgrounds where it would not wait until the full background is loaded.
Not sure if I got that or if I'm missing something: if you await the dispatch just the
setTitle
would need to wait. And that's something you could change by reversing the order. The loadList function then has to be async for sure. But since it's not awaited anywhere no code should wait.The only thing that changes is that the loadList returns a promise that says when it's finished. We don't need that right now, but if we do need it in the future the function is already prepared.
That's nice! BlurHash is really cool :)
Do you know sqip.
No idea how that compares, but I also always wanted to try that.
What I never got with BlurHash is why you would need to implement a new way of hashing images when you can just create a really small image as e.g. webp, inline that and blur it via CSS. Obviously that doesn't work as simple native so there you would need to adapt the implementation, something that BlurHash already does for you.
Ahh I just found this note:
See here: https://github.com/transitive-bullshit/lqip-modern#related
sqip looks great! Didn't know it before. I guess I'll do some experiments about the performance of both when it's time to implement it.