Skip to content

Make sure atomic user interactions result in "atomic" update actions #4281

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

Closed
philippotto opened this issue Sep 12, 2019 · 4 comments
Closed
Assignees
Labels

Comments

@philippotto
Copy link
Member

Prime example:
If I delete a group with 100 trees, this is essentially one user interaction. However, currently, we split this up into many update actions (which can easily exceed the undo stack size). This means, that there is no guaranteed undo for such actions, which is bad UX.

We should think about a way to make such actions "transactional" somehow. Can we use the transaction system we already have in the save queue?

Would like to hear your thoughts, @daniel-wer :)

@daniel-wer
Copy link
Member

I agree that this is definitely something we should fix/implement :)

Can we use the transaction system we already have in the save queue?

I thought about this but couldn't think of a good way yet, because the diffing is triggered each time a save-relevant action was dispatched and the diffing then dispatches the pushSaveQueueTransaction action.

Two possibilities that come to my mind:

  • Create actions + reducer (that reuse existing reducers) for these user interactions (probably most straightforward, but I'm not sure how many these would be)
  • Introduce some kind of begin/end transaction actions, so that diffing and undo-state collection can be deferred until the end_transaction action.

@philippotto
Copy link
Member Author

Great ideas! I think, both can work. Reading those, I just had another idea:

  • We could have a meta "batch" action which simply holds a set of other actions. The corresponding reducer would unpack these actions and call the generic reducer on them (without dispatching). The differ (and other components?) would probably need to do the unpacking, as well, but this might be straightforward.

Introduce some kind of begin/end transaction actions, so that diffing and undo-state collection can be deferred until the end_transaction action.

On a second thought, I think, there could be a risk that other actions could slip into unrelated transactions, if asynchronous actions are taking place. Might be very unlikely, but also very hard to debug in that case.

@daniel-wer
Copy link
Member

I found this while looking around which is pretty much what you proposed if I understood you correctly.

@philippotto
Copy link
Member Author

Awesome, yes, that's what I had in mind. With the middleware part, it's even better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants