-
-
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
Implement clearing of drawables with mouse #321
Conversation
if (ref?.current && !api) { | ||
if (ref?.current == null) return; | ||
if (api) { | ||
api?.set({ | ||
...props, | ||
events: { | ||
change: () => { | ||
if (props.setBoardFen && api) { | ||
props.setBoardFen(api.getFen()); | ||
} | ||
}, | ||
}, | ||
}); | ||
} else { |
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
} | ||
|
||
return state; |
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.
i assume this function is always supposed to return state
, but this branch previously returned nothing.
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.
The reducer can either return a new state, or simply mutate it when it's inside produce
from immer. Since the state is a tree, it can be annoying to ensure immutability, so a lot of these functions are inside produce which doesn't require a return.
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.
shall i change it back, or is a monomorphic return type acceptable here?
src/components/boards/Board.tsx
Outdated
<ActionIcon | ||
variant={editingMode ? "filled" : "default"} | ||
size="lg" | ||
onClick={() => setShapes([])} |
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.
Instead of setShapes
, there's already a clearShapes
function in store.ts which also sets the dirty flag.
thanks! |
2bba1c7
into
franciscoBSalgueiro:master
Removing drawables one-by-one is tedious. This affords an easy way to clear them by:
If the setting is enabled, the "Clear Drawings" button will not be rendered.
Translations for the setting were done with Google Translate.