<commit_before>kd           = require 'kd'
React        = require 'kd-react'
ReactDOM     = require 'react-dom'
immutable    = require 'immutable'
Link         = require 'app/components/common/link'
classnames   = require 'classnames'
ActivityFlux = require 'activity/flux'
ResultState  = require 'activity/constants/resultStates'

module.exports = class FeedPaneTabContainer extends React.Component

  @defaultProps =
    thread : immutable.Map()


  showPopularMessages: (event) ->

    kd.utils.stopDOMEvent event

    @handleRoute 'Liked'


  showMostRecentMessages: (event) ->

    kd.utils.stopDOMEvent event

    @handleRoute '/Recent'


  handleRoute: (route) ->

    channelName = @props.thread.getIn ['channel', 'name']
    route       = "/Channels/#{channelName}/#{route}"

    kd.singletons.router.handleRoute route


  getMostRecentTabClassNames: -> classnames
    'FeedPane-tab' : yes
    'active'       : @props.thread.getIn(['flags', 'resultListState']) is ResultState.RECENT


  getMostLikedTabClassNames: -> classnames
    'FeedPane-tab' : yes
    'active'       : @props.thread.getIn(['flags', 'resultListState']) is ResultState.LIKED


  render: ->

    return null  unless @props.thread

    <div className='FeedPane-tabContainer'>
      <Link
        onClick={@bound 'showPopularMessages'}
        className={@getMostLikedTabClassNames()}>Most Liked</Link>
      <Link<commit_msg>Client: Activity: Feed: Added onEsc and redirectToChannel methods<commit_after>kd           = require 'kd'
React        = require 'kd-react'
ReactDOM     = require 'react-dom'
immutable    = require 'immutable'
Link         = require 'app/components/common/link'
classnames   = require 'classnames'
ActivityFlux = require 'activity/flux'
ResultState  = require 'activity/constants/resultStates'

module.exports = class FeedPaneTabContainer extends React.Component

  @defaultProps =
    thread : immutable.Map()


  showPopularMessages: (event) ->

    kd.utils.stopDOMEvent event

    @handleRoute 'Liked'


  showMostRecentMessages: (event) ->

    kd.utils.stopDOMEvent event

    @handleRoute '/Recent'


  handleRoute: (route) ->

    channelName = @props.thread.getIn ['channel', 'name']
    route       = "/Channels/#{channelName}/#{route}"

    kd.singletons.router.handleRoute route


  getMostRecentTabClassNames: -> classnames
    'FeedPane-tab' : yes
    'active'       : @props.thread.getIn(['flags', 'resultListState']) is ResultState.RECENT


  getMostLikedTabClassNames: -> classnames
    'FeedPane-tab' : yes
    'active'       : @props.thread.getIn(['flags', 'resultListState']) is ResultState.LIKED


  onEsc: (event) -> @redirectToChannel()


  redirectToChannel: ->

    @setState query: ''

    channelName = @props.thread.getIn ['channel', 'name']

    ActivityFlux.actions.message.setChannelMessagesSearchQuery ''

    return kd.singletons.router.handleRoute "/Channels/#{channelName}"


  render: ->

    return null  unless @props.thread

    <div className='FeedPane-tabContainer'>
      <Link
        onClick={@bound 'showPopularMessages'}
        className={@getMostLikedTabClassNames()}>Most Liked</Link>
      <Link
{'fraction_non_alphanumeric': 0.12261753494282084, 'fraction_numerical': 0.0, 'mean_word_length': 3.428973277074543, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '6745590', 'n_tokens_mistral': 1004, 'n_tokens_neox': 939, 'n_words': 190}