Skip to content

Conversation

pedrokohler
Copy link
Collaborator

Fixes #288

Copy link

deepsource-io bot commented May 29, 2025

Here's the code health analysis summary for commits 279c46d..450d97d. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ Success
🎯 1 occurence resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

@pedrokohler
Copy link
Collaborator Author

@igoroctaviano FYI: It's impossible to satisfy all of the DeepSource requirements

My first commit had "this.handleVisibilityChange.bind(this)" and it said I shouldn't have .bind because it would be recalculated on every re-render

Then I changed it to (checked: boolean) => this.handleVisibilityChange(checked), and it said I shouldn't have a arrow function because of the same problem.

Finally, I used the constructor to bind the handleVisibilityChange function on the instantiation of the object, but now it's complaining that I shouldn't use "this.handleVisibilityChange" without binding it. So it's impossible to satisfy all of its requirements

@pedrokohler pedrokohler requested a review from igoroctaviano May 29, 2025 12:36
@igoroctaviano
Copy link
Collaborator

@pedrokohler cau take a look at deep source check?

@pedrokohler
Copy link
Collaborator Author

cau take a look at deep source check?

@igoroctaviano have you seen my previous comment?

@igoroctaviano
Copy link
Collaborator

@pedrokohler have you tried:

class AnnotationGroupList extends React.Component<
AnnotationGroupListProps,
unknown
> {
  handleVisibilityChange = (checked: boolean): void => {
    if (checked) {
      this.props.annotationGroups.forEach((annotationGroup) => {
        this.props.onAnnotationGroupVisibilityChange({
          annotationGroupUID: annotationGroup.uid,
          isVisible: checked
        })
      })
      return
    }

    this.props.visibleAnnotationGroupUIDs.forEach((annotationGroupUID) => {
      this.props.onAnnotationGroupVisibilityChange({
        annotationGroupUID,
        isVisible: checked
      })
    })
  }

This does not require a constructor or bind, and it does not create an arrow function all the time, since it's a class assignment.

Copy link

@pedrokohler
Copy link
Collaborator Author

@igoroctaviano everything is passing now.

@pedrokohler pedrokohler merged commit de550c0 into master May 30, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add control to toggle all annotation groups at once
2 participants