 
   advanceToNextSubject: ->
     console.log 'advanceToNextSubject()'
-    currentIndex = (i for s, i in @state.subjects when s['id'] == @state.currentSubject['id'])[0]
     # console.log "subjects: ", @state.subjects
-    if currentIndex + 1 < @state.subjects.length
-      nextSubject = @state.subjects[currentIndex + 1]
-      console.log 'NEXT SUBJECT: ', nextSubject
-      console.log 'NEXT TASK KEY: ', nextSubject.type
+    if @state.subject_index + 1 < @state.subjects.length
+      next_index = @state.subject_index + 1
+      next_subject = @state.subjects[next_index]
+      console.log 'NEXT SUBJECT: ', next_subject
       @setState
-        taskKey: nextSubject.type
-        currentSubject: nextSubject
+        taskKey: next_subject.type
+        subject_index: next_index
         , =>
-          key = @state.currentSubject.type
+          key = @getCurrentSubject().type
           @advanceToTask key
     else
       console.warn "WARN: End of subjects"


module.exports = React.createClass # rename to Classifier
  displayName: 'Transcribe'
  mixins: [FetchSubjectsMixin, BaseWorkflowMethods] # load subjects and set state variables: subjects, currentSubject, classification

  getInitialState: ->
    workflow:                     @props.workflow
    currentSubject:               null
    taskKey:                      null
    classifications:              []
    classificationIndex:          0


  componentWillMount: ->
    @beginClassification()

  fetchSubjectsCallback: ->
    console.log 'fetchSubjectsCallback(), TASK KEY  = ', @state.currentSubject.type
    #TODO: We do need to account for times when there are no subjects? type won't do that. -AMS

    @setState taskKey: @state.currentSubject.type
    # @advanceToTask new_key

  handleTaskComponentChange: (val) ->

            </div>

            <div className="forum-holder">
              <ForumSubjectWidget subject_set=@getCurrentSubject() />
            </div>

          </div>
