-
Notifications
You must be signed in to change notification settings - Fork 10
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
Separate clear functions for undo-/redo-stacks #36
Comments
Thank you for your answer. While yes, they are similiar in that this feature also would not reset the state, I think they are still different enough, as this feature would allow the clearing of both stacks individually at the devs discretion, instead of always both at the same time. |
Hello, I am currently developing this feature. What are the requirements for an acceptable pull request? |
Hi @pi3n4t sorry for the delay in getting back. Thanks for your time in developing and contributing to this project. 👍 I would say these would be some general guidelines:
|
Thank you for the answer. Expected Features
These functions will not call the action RESET_STATE, but will update canUndoRedo. Feedback would be appreciated, as I am not too sure I understood all intentions in how the code was structured correctly. |
@pi3n4t Did you ever find a workaround? |
@tobiascornille I think so, yes. At some point I had something working, but didn't get the chance to test it enough to be sure that it's correct. Projects and scope changed. That is why I haven't submitted any code so far. But here is what I did anyway: First I had to create the function async (namespace: string) => {
const config = getConfig(paths)(namespace);
if (Object.keys(config).length) {
const undone: [] = [];
setConfig(paths)(
namespace,
{
...config,
undone
},
store
);
updateCanUndoRedo({ paths, store })(namespace);
}
}; This function then also has to be exposed so you can call it from outside the module. IIRC you have to add some things in You could now call this action every time you call another action. I thought that's annoying though, so I wrote another vuex plugin that you can just add when intializing it. It looks something like this: export default function emptyUndoneStack(store) {
store.subscribeAction((action, state) => {
if (
state.undoRedoConfig.undone
&& state.undoRedoConfig.undone.length
&& action.type !== 'undo'
) {
store.dispatch('resetUndone');
}
});
} This function get's called for every action that you dispatch. In theory you could create a white-/blacklist to only clear the undone stack when certain actions are called. |
@pi3n4t Thank you for the write-up! |
Being able to clear both stacks individually would make it able to mimic the behaviour in most office-like apps, as the redo-stack gets cleared when making changes.
This would require the state to not get reset after clearing.
The text was updated successfully, but these errors were encountered: