-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f910698
commit ca08eac
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export const EMPTY_STATE = "emptyState"; | ||
export const RESET_STATE = "resetState"; | ||
export const UPDATE_CAN_UNDO_REDO = "updateCanUndoRedo"; | ||
export const REDO = "redo"; | ||
export const UNDO = "undo"; | ||
export const CLEAR = "clear"; | ||
export const RESET = "reset"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { RESET_STATE } from "./constants"; | ||
import { | ||
getConfig, | ||
setConfig, | ||
updateCanUndoRedo | ||
} from "./utils-undo-redo"; | ||
|
||
export default ({ | ||
paths, | ||
store | ||
}: { | ||
paths: UndoRedoOptions[]; | ||
store: any; | ||
}) => async (namespace: string) => { | ||
const config = getConfig(paths)(namespace); | ||
|
||
if (Object.keys(config).length) { | ||
const done: [] = []; | ||
const undone: [] = []; | ||
config.newMutation = false; | ||
store.commit(`${namespace}${RESET_STATE}`); | ||
|
||
config.newMutation = true; | ||
|
||
setConfig(paths)(namespace, { | ||
...config, | ||
done, | ||
undone | ||
}); | ||
|
||
updateCanUndoRedo({ paths, store })(namespace); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters