<commit_before>kd              = require 'kd'
React           = require 'kd-react'
immutable       = require 'immutable'
ActivityFlux    = require 'activity/flux'
ChatPane        = require 'activity/components/chatpane'
ChatInputWidget = require 'activity/components/chatinputwidget'

module.exports = class PrivateChatPane extends React.Component

  @defaultProps =
    thread   : immutable.Map()
    messages : immutable.List()


  channel: (key) -> @props.thread?.getIn ['channel', key]


  onSubmit: ({ value }) ->

    return  unless body = value

    ActivityFlux.actions.message.createMessage @channel('id'), body


  onLoadMore: ->

    return  unless @props.messages.size
    return  if @props.thread.getIn ['flags', 'isMessagesLoading']

    from = @props.messages.first().get('createdAt')
    kd.utils.defer => ActivityFlux.actions.message.loadMessages @channel('id'), { from }


  render: ->

    <ChatPane
      thread     = { @props.thread }
      className  = 'PrivateChatPane'
      messages   = { @props.messages }
      onSubmit   = { @bound 'onSubmit' }
      onLoadMore = { @bound 'onLoadMore' }
    >
      <footer className='PrivateChatPane-footer'>
        <ChatInputWidget
          onSubmit     = { @bound 'onSubmit' }<commit_msg>activity: focus to input after clicking invite link in private channels<commit_after>kd              = require 'kd'
React           = require 'kd-react'
immutable       = require 'immutable'
ActivityFlux    = require 'activity/flux'
ChatPane        = require 'activity/components/chatpane'
ChatInputWidget = require 'activity/components/chatinputwidget'

module.exports = class PrivateChatPane extends React.Component

  @defaultProps =
    thread   : immutable.Map()
    messages : immutable.List()


  channel: (key) -> @props.thread?.getIn ['channel', key]


  onSubmit: ({ value }) ->

    return  unless body = value

    ActivityFlux.actions.message.createMessage @channel('id'), body


  onLoadMore: ->

    return  unless @props.messages.size
    return  if @props.thread.getIn ['flags', 'isMessagesLoading']

    from = @props.messages.first().get('createdAt')
    kd.utils.defer => ActivityFlux.actions.message.loadMessages @channel('id'), { from }


  afterInviteOthers: ->

    return  unless input = @refs.chatInputWidget

    input.focus()


  render: ->

    <ChatPane
      thread     = { @props.thread }
      className  = 'PrivateChatPane'
      messages   = { @props.messages }
      onSubmit   = { @bound 'onSubmit' }
      afterInviteOthers = {@bound 'afterInviteOthers'}
      onLoadMore = { @bound 'onLoadMore' }
    >
      <footer className='PrivateChatPane-footer'>
        <ChatInputWidget
          ref          = 'chatInputWidget'
          onSubmit     = { @bound 'onSubmit' }
{'fraction_non_alphanumeric': 0.11988409996378124, 'fraction_numerical': 0.0, 'mean_word_length': 2.8521617852161785, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 18, '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': '3400019', 'n_tokens_mistral': 824, 'n_tokens_neox': 793, 'n_words': 175}