feat: support props.locked for setActiveTool (#7153)

Co-authored-by: Aakansha Doshi <aakansha1216@gmail.com>
This commit is contained in:
David Luzar 2023-10-20 13:16:23 +02:00 committed by GitHub
parent e7cc2337ea
commit 3697618266
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 5 deletions

View file

@ -363,18 +363,21 @@ export const distance = (x: number, y: number) => Math.abs(x - y);
export const updateActiveTool = (
appState: Pick<AppState, "activeTool">,
data: (
data: ((
| {
type: ToolType;
}
| { type: "custom"; customType: string }
) & { lastActiveToolBeforeEraser?: ActiveTool | null },
) & { locked?: boolean }) & {
lastActiveToolBeforeEraser?: ActiveTool | null;
},
): AppState["activeTool"] => {
if (data.type === "custom") {
return {
...appState.activeTool,
type: "custom",
customType: data.customType,
locked: data.locked ?? appState.activeTool.locked,
};
}
@ -386,6 +389,7 @@ export const updateActiveTool = (
: data.lastActiveToolBeforeEraser,
type: data.type,
customType: null,
locked: data.locked ?? appState.activeTool.locked,
};
};