<commit_before>React = require 'react/addons'
Reflux = require 'reflux'
counterpart = require 'counterpart'
Translate = require 'react-translate-component'

LoadingIndicator = require '../components/loading-indicator'
SlideTutorial = require '../components/slide-tutorial'

annotationsStore = require '../stores/annotations-store'
classifierStore = require '../stores/classifier-store'
subjectStore = require '../stores/subject-store'
workflowStore = require '../stores/workflow-store'

classifierActions = require '../actions/classifier-actions'

Task = require '../tasks/survey'
Summary = require '../tasks/survey/summary'

module.exports = React.createClass
  displayName: "Classify"
  mixins: [
    Reflux.connect annotationsStore, 'annotations'
    Reflux.connect classifierStore
    Reflux.connect subjectStore, 'subject'
    Reflux.connect workflowStore, 'workflow'
  ]

  getInitialState: ->
    annotations: annotationsStore.data
    workflow: workflowStore.data
    subject: subjectStore.data
    showingSummary: classifierStore.data.showingSummary
    tutorialIsOpen: classifierStore.data.tutorialIsOpen

  componentDidMount: ->
    # Check specifically for null because setting prop as null if no user is returned. Avoids loading tutorial for the split second the props are undefined.
    # For logged in users with zero classifications, they will have null userPrefs
    if @props.user is null || @props.userPreferences is null
      classifierActions.displayTutorial()

  componentWillReceiveProps: (nextProps) ->
    if nextProps.userPreferences?.activity_count is 0 or nextProps.userPreferences is null<commit_msg>Bugfix initial tutorial state<commit_after>React = require 'react/addons'
Reflux = require 'reflux'
counterpart = require 'counterpart'
Translate = require 'react-translate-component'

LoadingIndicator = require '../components/loading-indicator'
SlideTutorial = require '../components/slide-tutorial'

annotationsStore = require '../stores/annotations-store'
classifierStore = require '../stores/classifier-store'
subjectStore = require '../stores/subject-store'
workflowStore = require '../stores/workflow-store'

classifierActions = require '../actions/classifier-actions'

Task = require '../tasks/survey'
Summary = require '../tasks/survey/summary'

module.exports = React.createClass
  displayName: "Classify"
  mixins: [
    Reflux.connect annotationsStore, 'annotations'
    Reflux.connect classifierStore
    Reflux.connect subjectStore, 'subject'
    Reflux.connect workflowStore, 'workflow'
  ]

  getInitialState: ->
    annotations: annotationsStore.data
    workflow: workflowStore.data
    subject: subjectStore.data
    showingSummary: classifierStore.data.showingSummary
    shownTutorial: classifierStore.data.shownTutorial
    tutorialIsOpen: classifierStore.data.tutorialIsOpen

  componentDidMount: ->
    # Check specifically for null because setting prop as null if no user is returned. Avoids loading tutorial for the split second the props are undefined.
    # For logged in users with zero classifications, they will have null userPrefs
    if @props.user is null || @props.userPreferences is null
      classifierActions.displayTutorial()

  componentWillReceiveProps: (nextProps) ->
    if nextProps.userPreferences?.activity_count is 0 or nextProps.userPreferences is null
{'fraction_non_alphanumeric': 0.0921921921921922, 'fraction_numerical': 0.0006006006006006006, 'mean_word_length': 4.5889261744966445, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4002094', 'n_tokens_mistral': 914, 'n_tokens_neox': 868, 'n_words': 248}