Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Unfiltered snapshots feature - #139

Merged
omnidan merged 11 commits into
omnidan:masterfrom
davidroeca:master
Dec 20, 2016
Merged

omnidan merged 11 commits into
omnidan:masterfrom
davidroeca:master

Conversation

@davidroeca

Copy link
Copy Markdown
Collaborator

This pull request removes the wasFiltered flag (the source of a number of bugs), and replaces it with a _latestUnfiltered state object. The purpose of this object is to track the most recent unfiltered state, in order save the correct state object to the past at the correct time (not too early).

The basic premise:
-When updating new (unfiltered) present state, push _latestUnfiltered to the past stack (if it exists), and update both the present and _latestUnfiltered state objects with the latest state
-When inserting filtered present state, merely update the present state
-When undoing, push the _latestUnfiltered state to the future stack, and update both the present and _latestUnfiltered state objects to the most recent past
-When redoing, push the _latestUnfiltered state to the past stack, and update both the present and _latestUnfiltered state objects to the nearest future

I've also updated the unit tests to account for this; let me know if you have any questions/concerns


Example functionality changes

Actions:
Action A = unfiltered action
Action F = filtered action (typically fired by a thunk for redux form's internal state)

Before this pull request:
1: Action A happens
2: Action F happens <--- line 1's state is added to past (Undo will have to be clicked 1 too many times!)
3: Action F happens
4: Action A happens
5: Action F happens <--- line 4's state is added to past
6. Action A happens

After this pull request:
1: Action A happens <--- snapshot of "most recent unfiltered state" is taken
2: Action F happens
3: Action F happens
4: Action A happens <--- line 1's state is added to past; snapshot of "most recent unfiltered state" is taken
5: Action F happens
6. Action A happens <--- line 4's state is added to past; snapshot of "most recent unfiltered state" is taken

@davidroeca davidroeca mentioned this pull request Dec 12, 2016
@omnidan

omnidan commented Dec 20, 2016

Copy link
Copy Markdown
Owner

Thanks a lot for this PR, @davidroeca - looks really good! 👌

@omnidan
omnidan merged commit 41af3d6 into omnidan:master Dec 20, 2016
@omnidan

omnidan commented Dec 20, 2016

Copy link
Copy Markdown
Owner

@davidroeca can you join us on gitter? 😁

@omnidan

omnidan commented Dec 20, 2016

Copy link
Copy Markdown
Owner

I published a new version beta9-3 with this fix, let me know if everything works fine now!

@jcdufourd

jcdufourd commented May 8, 2017 •

Copy link
Copy Markdown

This "fix" makes it impossible to create a filter to squash multiple identical actions into one single undo. This fix restores the state after the first action, instead of the state after the last of the multiple actions, which defeats the purpose. Maybe it fixes another use case, but mine seems important too...

@davidroeca

Copy link
Copy Markdown
Collaborator Author

Hi @jcdufourd,

Strange, when I made this PR I was working with libraries that relied a lot on thunks and had similar behavior in mind. Please reopen #115 or open a new issue and provide a simple case of where this doesn't work out for you. Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants