context = window
MIX_MODES = context.JK.MIX_MODES
logger = context.JK.logger

@SessionMediaTracksMixin = {

  metronomeTrulyGoneCheck: () ->

    logger.debug("metronome is completely gone")
    @setState({metronomeFlickerTimeout: null})

  onInputsChanged: (sessionMixers) ->

    session = sessionMixers.session
    mixers = sessionMixers.mixers

    # the backend delete/adds the metronome rapidly when the user hits play. this is custom code to deal with that

    if mixers.mediaSummary.isOpener
      mediaCategoryMixer = mixers.getMediaCategoryMixer(@props.mode)
    else
      mediaCategoryMixer = mixers.getUserMediaCategoryMixer(@props.mode)

    state =
      isRecording: session.isRecording
      mediaSummary: mixers.mediaSummary
      backingTracks: mixers.backingTracks
      jamTracks: mixers.jamTracks
      recordedTracks: mixers.recordedTracks
      metronome: mixers.metronome
      mediaCategoryMixer: mediaCategoryMixer
      recordingName: mixers.recordingName()
      jamTrackName: mixers.jamTrackName()
      jamTrackMixdown: session.jamTrackMixdown()

    @inputsChangedProcessed(state) if @inputsChangedProcessed?

    @setState(state)

}