Skip to content

Commit

Permalink
fix: Undo/redo fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
petejohanson committed Jul 12, 2024
1 parent 28f2625 commit 8b25218
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/undoRedo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ export function useUndoRedo(): [
[locked, redoStack]
);

const doIt = async (doCb: DoCallback) => {
const doIt = async (doCb: DoCallback, preserveRedo?: boolean) => {
setLocked(true);
let undo = await doCb();

setUndoStack([[doCb, undo], ...undoStack]);
if (!preserveRedo) {
setRedoStack([]);
}
setLocked(false);
};

Expand Down Expand Up @@ -67,7 +70,7 @@ export function useUndoRedo(): [

setRedoStack(redoStack.slice(1));

return await doIt(doCb);
return await doIt(doCb, true);
};

const reset = () => {
Expand Down

0 comments on commit 8b25218

Please sign in to comment.