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

@SessionMasterMyTracks = React.createClass({

  mixins: [Reflux.listenTo(@SessionMyTracksStore,"onInputsChanged")]


  onInputsChanged: (update) ->
    this.setState(update)

  render: () ->

    content = null
    tracks = []

    if this.state.tracks.length > 0
      for track in this.state.tracks
        track.mode = @props.mode
        tracks.push(`<SessionMyTrack key={track.track.client_track_id} {...track} />`)

      if @state.chat
        @state.chat.mode = @props.mode
        tracks.push(`<SessionMyChat key="chat" {...this.state.chat} />`)

    else if this.state.session? && this.state.session.inSession()
      logger.debug("no 'my inputs' for master mix")

    `<div className="session-my-tracks">
      <h2>audio tracks</h2>
      <div className="session-tracks-scroller">
        {content}
        {tracks}
      </div>
    </div>`

  getInitialState:() ->
    {tracks:[], session: null, chat:null}

})
