<commit_before>React = require 'react'
createReactClass = require 'create-react-class'

HidePreviousMarksToggle = createReactClass
  getDefaultProps: ->
    taskTypes: null
    workflow: null
    classification: null
    onChange: ->

  getInitialState: ->
    checked: false

  setPreviousMarks: (count) ->
    @props.classification._hideMarksBefore = count
    checked = count > 0
    @setState { checked }
    # this is a hack to force the parent to render again with marks hidden
    annotations = @props.classification.annotations.slice()
    annotation = annotations[annotations.length - 1]
    @props.onChange annotation

  render: ->
    annotations = @props.classification.annotations
    currentAnnotation = annotations[annotations.length-1]<commit_msg>Update parent on change Call the onChange callback after a state change, to force a re-render of the parent if required.<commit_after>React = require 'react'
createReactClass = require 'create-react-class'

HidePreviousMarksToggle = createReactClass
  getDefaultProps: ->
    taskTypes: null
    workflow: null
    classification: null
    onChange: ->

  getInitialState: ->
    checked: false

  setPreviousMarks: (count) ->
    @props.classification._hideMarksBefore = count
    checked = count > 0
    @setState { checked }
    @updateParent()

  updateParent: () ->
    annotations = @props.classification.annotations.slice()
    annotation = annotations[annotations.length - 1]
    @props.onChange annotation

  render: ->
    annotations = @props.classification.annotations
    currentAnnotation = annotations[annotations.length-1]
{'fraction_non_alphanumeric': 0.0886945658963148, 'fraction_numerical': 0.0037476577139287947, 'mean_word_length': 3.7964071856287425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2766916', 'n_tokens_mistral': 438, 'n_tokens_neox': 419, 'n_words': 115}