Skip to content
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

Fix undo-manager not working on child trees #875

Merged
merged 1 commit into from
Jun 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/mst-middlewares/src/undo-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const UndoManager = types
return {
addUndoState(recorder: any) {
if (replaying || (recorder.patches && recorder.patches.length === 0)) {
// skip recording if this state was caused by undo / redo
// skip recording if this state was caused by undo / redo
// or if patches is empty
return
}
Expand All @@ -145,13 +145,13 @@ const UndoManager = types
self.undoIdx--
// n.b: reverse patches back to forth
// TODO: add error handling when patching fails? E.g. make the operation atomic?
applyPatch(targetStore, self.history[self.undoIdx].inversePatches.slice().reverse())
applyPatch(getRoot(targetStore), self.history[self.undoIdx].inversePatches.slice().reverse())
replaying = false
},
redo() {
replaying = true
// TODO: add error handling when patching fails? E.g. make the operation atomic?
applyPatch(targetStore, self.history[self.undoIdx].patches)
applyPatch(getRoot(targetStore), self.history[self.undoIdx].patches)
self.undoIdx++
replaying = false
},
Expand Down