Every mutation/action stores a new snapshot of the state. Undoing simply sets the state to a previous snapshot of the state. Could face issues with memory. Likely need to enforce an upper limit of snapshots saved. ~100?
Requires less work... And covers any edge cases where tool/UI state also needs to be updated, e.g. the selected dots and selected stuntsheet may be different after an undo.
Also, need a distinction between which actions we should save state for or not. For example, setting the tool dots should not save a new snapshot of the state. Also, what should be stored (we don't need to store everything)?
Implement a paired undo mutation for any given mutation
Every mutation has another mutation that undos the previous mutation's changes. This way we don't have to store snapshots of the state.
May need to implement a "permanent" vs "temporary" storage, where "temporary" state can be thrown out after exiting the program, or maybe after undo/redo? E.g. the selected stuntsheet or selected dots.
Check out a VueX extension that implements undo/redo for us
Note: the state only "moves forward"; e.g. an undo action is added to the timeline.
Probably over-kill for us!
Closure map
The "new" and "old" maps can point to the same data, but any difference between the two can be saved in the separate maps. Lower storage costs since common data can be shared between snapshots.
Possible solutions of undo/redo:
Store snapshots of state
Every mutation/action stores a new snapshot of the state. Undoing simply sets the state to a previous snapshot of the state. Could face issues with memory. Likely need to enforce an upper limit of snapshots saved. ~100?
Requires less work... And covers any edge cases where tool/UI state also needs to be updated, e.g. the selected dots and selected stuntsheet may be different after an undo.
Also, need a distinction between which actions we should save state for or not. For example, setting the tool dots should not save a new snapshot of the state. Also, what should be stored (we don't need to store everything)?
Implement a paired undo mutation for any given mutation
Every mutation has another mutation that undos the previous mutation's changes. This way we don't have to store snapshots of the state.
May need to implement a "permanent" vs "temporary" storage, where "temporary" state can be thrown out after exiting the program, or maybe after undo/redo? E.g. the selected stuntsheet or selected dots.
Check out a VueX extension that implements undo/redo for us
emacs undo tree
https://frozenlock.files.wordpress.com/2012/04/wpid-undo-tree.png
Note: the state only "moves forward"; e.g. an undo action is added to the timeline.
Probably over-kill for us!
Closure map
The "new" and "old" maps can point to the same data, but any difference between the two can be saved in the separate maps. Lower storage costs since common data can be shared between snapshots.