+_                                 = require 'lodash'
 kd                                = require 'kd'
 Link                              = require 'app/components/common/link'
 React                             = require 'kd-react'

AppFlux                           = require 'app/flux'
TextArea                          = require 'react-autosize-textarea'
classnames                        = require 'classnames'
KeyboardKeys                      = require 'app/util/keyboardKeys'
ActivityFlux                      = require 'activity/flux'
ActivityModal                     = require 'app/components/activitymodal'

    CreateChannelFlux.actions.user.resetSelectedIndex()
    CreateChannelFlux.actions.user.unsetInputQuery()
    CreateChannelFlux.actions.channel.removeAllParticipants()


  componentDidUpdate: (oldProps, oldState) ->

    if oldState.participants isnt @state.participants

      unless @state.participants?.size
        return @setState { preExistingChannel: null }

      participants = @state.participants
        .map (participant) -> participant.get 'socialApiId'
        .toList()
        .toJS()

      { loadChannelByParticipants } = ActivityFlux.actions.channel

      loadChannelByParticipants(participants).then ({ channels }) =>
        if channels.length
          @setState { preExistingChannel: toImmutable channels[0] }
        else
          @setState { preExistingChannel: null }


  getDataBindings: ->
