-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
delete tag through context menu #2497
Conversation
@@ -65,7 +65,7 @@ class MarkdownNoteDetail extends React.Component { | |||
} | |||
|
|||
componentWillReceiveProps (nextProps) { | |||
if (nextProps.note.key !== this.props.note.key && !this.state.isMovingNote) { | |||
if (!this.state.isMovingNote && (nextProps.note.key !== this.props.note.key || nextProps.note.tags.length < this.props.note.tags.length)) { |
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.
This condition is really long and may confuse new contributors, can you assign some parts of the condition into variables with meaningful names?
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.
So that's is the reason for temporary variables I've seen in the code.
It's to increase the readability of the code 👍
if (
!this.state.isMovingNote &&
(
// if it's a new note
nextProps.note.key !== this.props.note.key ||
// if there is deleted tags
nextProps.note.tags.length < this.props.note.tags.length
)
) {
const isNewNote = nextProps.note.key !== this.props.note.key
const hasDeletedTags = nextProps.note.tags.length < this.props.note.tags.length
if (!this.state.isMovingNote && (isNewNote || hasDeletedTags)) {
I can see why it is more readable 😉
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.
LGTM 🎉
This change adds the possibility to delete a tag through its context menu.