Skip to content

Commit

Permalink
refactor: rename undo cmds
Browse files Browse the repository at this point in the history
  • Loading branch information
cidhuang committed May 20, 2024
1 parent dd0a628 commit 1a630b6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/components/SystemMapCanvas/SystemMapCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export const SystemMapCanvas = forwardRef<
modes: modes,
state: EStateCanvas.Idle,
items: items,
cmdUndoAdd: 0,
cmdUndoReset: 0,
cmdUndoSetItems: 0,
cmdUndoResetItems: 0,
});

const [
Expand Down Expand Up @@ -159,7 +159,7 @@ export const SystemMapCanvas = forwardRef<
onItemsChange(state.items);

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state.cmdUndoAdd]);
}, [state.cmdUndoSetItems]);

useEffect(() => {
dispatch({ type: "NewMap", items: items });
Expand All @@ -177,7 +177,7 @@ export const SystemMapCanvas = forwardRef<
resetItems(state.items);

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [state.cmdUndoReset]);
}, [state.cmdUndoResetItems]);

function editTextStart(item: string) {
if (isVariable(item)) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/SystemMapCanvas/reducer/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function reducerChangeItems(
...state,
state: EStateCanvas.Idle,
items: items,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand All @@ -102,7 +102,7 @@ export function reducerNewMap(
...state,
state: EStateCanvas.Idle,
items: action.items,
cmdUndoReset: state.cmdUndoReset + 1,
cmdUndoResetItems: state.cmdUndoResetItems + 1,
};
}

Expand Down
28 changes: 14 additions & 14 deletions src/components/SystemMapCanvas/reducer/reducerMouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function removeVariable(state: IStateCanvas, item: string): IStateCanvas {
return {
...state,
items: items,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand All @@ -102,7 +102,7 @@ function variableToStock(state: IStateCanvas, item: string): IStateCanvas {
return {
...state,
items: items,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand All @@ -112,7 +112,7 @@ function stockToVariable(state: IStateCanvas, item: string): IStateCanvas {
return {
...state,
items: items,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand All @@ -124,7 +124,7 @@ function removeLink(state: IStateCanvas, item: string): IStateCanvas {
return {
...state,
items: items,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand All @@ -142,7 +142,7 @@ function toggleLinkRelation(state: IStateCanvas, item: string): IStateCanvas {
return {
...state,
items: items,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand All @@ -162,7 +162,7 @@ function toggleLinkDirection(state: IStateCanvas, item: string): IStateCanvas {
return {
...state,
items: items,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand All @@ -172,7 +172,7 @@ function reverseFlowDirection(state: IStateCanvas, item: string): IStateCanvas {
return {
...state,
items: items,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand All @@ -183,7 +183,7 @@ function reducerIdleDoubleClick(state: IStateCanvas, xy: Point, item: string) {
return {
...state,
items: items,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand Down Expand Up @@ -246,7 +246,7 @@ function reducerMovingVariableUp(state: IStateCanvas, xy: Point, item: string) {
return {
...state,
state: EStateCanvas.Idle,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand All @@ -263,7 +263,7 @@ function reducerMovingStockUp(state: IStateCanvas, xy: Point, item: string) {
return {
...state,
state: EStateCanvas.Idle,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand All @@ -289,7 +289,7 @@ function reducerShapingLinkUp(state: IStateCanvas, xy: Point, item: string) {
return {
...state,
state: EStateCanvas.Idle,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand All @@ -306,7 +306,7 @@ function reducerShapingFlowUp(state: IStateCanvas, xy: Point, item: string) {
return {
...state,
state: EStateCanvas.Idle,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}

Expand Down Expand Up @@ -358,7 +358,7 @@ function reducerDragginNewLinkFlowUp(
...state,
state: EStateCanvas.Idle,
items: items,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
dragLinkEnd: undefined,
};
}
Expand All @@ -379,7 +379,7 @@ function reducerDragginNewLinkFlowUp(
...state,
state: EStateCanvas.Idle,
items: items,
cmdUndoAdd: state.cmdUndoAdd + 1,
cmdUndoSetItems: state.cmdUndoSetItems + 1,
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/SystemMapCanvas/reducer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export interface IStateCanvas {
modes: IStateCanvasModes;
state: EStateCanvas;
items: IItems;
cmdUndoAdd: number;
cmdUndoReset: number;
cmdUndoSetItems: number;
cmdUndoResetItems: number;
dragStart?: string;
dragLinkEnd?: string | Point;
dragLinkMid?: Point;
Expand Down

0 comments on commit 1a630b6

Please sign in to comment.