-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
Implement clearing of drawables with mouse #321
Changes from all commits
8ac4ec9
c94a8cc
8b11093
2a1ba1c
1093429
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -468,9 +468,9 @@ export const createTreeStore = (id?: string, initialTree?: TreeState) => { | |
clearShapes: () => | ||
set( | ||
produce((state) => { | ||
state.dirty = true; | ||
const node = getNodeAtPath(state.root, state.position); | ||
if (node) { | ||
if (node && node.shapes.length > 0) { | ||
state.dirty = true; | ||
node.shapes = []; | ||
} | ||
}), | ||
|
@@ -640,16 +640,23 @@ function promoteVariation(state: TreeState, path: number[]) { | |
function setShapes(state: TreeState, shapes: DrawShape[]) { | ||
const node = getNodeAtPath(state.root, state.position); | ||
if (!node) return state; | ||
const shape = shapes[0]; | ||
const index = node.shapes.findIndex( | ||
(s) => s.orig === shape.orig && s.dest === shape.dest, | ||
); | ||
|
||
if (index !== -1) { | ||
node.shapes.splice(index, 1); | ||
const [shape] = shapes; | ||
if (shape) { | ||
const index = node.shapes.findIndex( | ||
(s) => s.orig === shape.orig && s.dest === shape.dest, | ||
); | ||
|
||
if (index !== -1) { | ||
node.shapes.splice(index, 1); | ||
} else { | ||
node.shapes.push(shape); | ||
} | ||
} else { | ||
node.shapes.push(shape); | ||
node.shapes = []; | ||
} | ||
|
||
return state; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i assume this function is always supposed to return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reducer can either return a new state, or simply mutate it when it's inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shall i change it back, or is a monomorphic return type acceptable here? |
||
} | ||
|
||
function addAnalysis( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixing a nit