<commit_before>kd          = require 'kd'
actionTypes = require './actiontypes'

{ actions: appActions } = require 'app/flux'


dispatch = (args...) -> kd.singletons.reactor.dispatch args...


###*
 * Action to set current query of chat input users.
 * Also, it resets users selected index and loads users
 * filtered by query if query is not empty
 *
 * @param {string} stateId
 * @param {string} query
###
setQuery = (stateId, query) ->

  if query
    { SET_CHAT_INPUT_USERS_QUERY } = actionTypes
    dispatch SET_CHAT_INPUT_USERS_QUERY, { stateId, query }
    resetSelectedIndex stateId
    appActions.user.searchAccounts query
  else
    unsetQuery stateId


###*
 * Action to unset current query of chat input users.
 * Also, it resets users selected index
 *
 * @param {string} stateId
###
unsetQuery = (stateId) ->

  { UNSET_CHAT_INPUT_USERS_QUERY } = actionTypes
  dispatch UNSET_CHAT_INPUT_USERS_QUERY, { stateId }

  resetSelectedIndex stateId


###*
 * Action to set selected index of chat input users
 *
 * @param {string} stateId
 * @param {number} index
###
setSelectedIndex = (stateId, index) ->

  { SET_CHAT_INPUT_USERS_SELECTED_INDEX } = actionTypes
  dispatch SET_CHAT_INPUT_USERS_SELECTED_INDEX, { stateId, index }


###*
 * Action to increment users selected index
 *
 * @param {string} stateId
###
moveToNextIndex = (stateId) ->

  { MOVE_TO_NEXT_CHAT_INPUT_USERS_INDEX } = actionTypes
  dispatch MOVE_TO_NEXT_CHAT_INPUT_USERS_INDEX, { stateId }


###*
 * Action to decrement users selected index
 *
 * @param {string} stateId
###
moveToPrevIndex = (stateId) ->

  { MOVE_TO_PREV_CHAT_INPUT_USERS_INDEX } = actionTypes
  dispatch MOVE_TO_PREV_CHAT_INPUT_USERS_INDEX, { stateId }


###*
 * Action to reset users selected index
 *
 * @param {string} stateId
###
resetSelectedIndex = (stateId) ->

  { RESET_CHAT_INPUT_USERS_SELECTED_INDEX } = actionTypes
  dispatch RESET_CHAT_INPUT_USERS_SELECTED_INDEX, { stateId }


###*
 * Action to set visibility of chat input users
 *
 * @param {string} stateId
 * @param {bool} visible
###
setVisibility = (stateId, visible) ->

  { SET_CHAT_INPUT_USERS_VISIBILITY } = actionTypes
  dispatch SET_CHAT_INPUT_USERS_VISIBILITY, { stateId, visible }


###*
 * Action to increment users selected index
###
moveToNextChannelParticipantIndex = ->

  { MOVE_TO_NEXT_CHANNEL_PARTICIPANT_INDEX } = actionTypes
  dispatch MOVE_TO_NEXT_CHANNEL_PARTICIPANT_INDEX


###*
 * Action to decrement users selected index
###
moveToPrevChannelParticipantIndex = ->

  { MOVE_TO_PREV_CHANNEL_PARTICIPANT_INDEX } = actionTypes
  dispatch MOVE_TO_PREV_CHANNEL_PARTICIPANT_INDEX


module.exports = {
  setQuery
  unsetQuery
  setSelectedIndex
  moveToNextIndex
  moveToPrevIndex
  resetSelectedIndex
  setVisibility
  moveToNextChannelParticipantIndex
  moveToPrevChannelParticipantIndex
}
<commit_msg>Client: Activity: Created setChannelParticipantsInputQuery action. It dispatches SET_PARTICIPANT_USERS_QUERY and searchAccounts by query<commit_after>kd          = require 'kd'
actionTypes = require './actiontypes'

{ actions: appActions } = require 'app/flux'


dispatch = (args...) -> kd.singletons.reactor.dispatch args...


###*
 * Action to set current query of chat input users.
 * Also, it resets users selected index and loads users
 * filtered by query if query is not empty
 *
 * @param {string} stateId
 * @param {string} query
###
setQuery = (stateId, query) ->

  if query
    { SET_CHAT_INPUT_USERS_QUERY } = actionTypes
    dispatch SET_CHAT_INPUT_USERS_QUERY, { stateId, query }
    resetSelectedIndex stateId
    appActions.user.searchAccounts query
  else
    unsetQuery stateId


###*
 * Action to unset current query of chat input users.
 * Also, it resets users selected index
 *
 * @param {string} stateId
###
unsetQuery = (stateId) ->

  { UNSET_CHAT_INPUT_USERS_QUERY } = actionTypes
  dispatch UNSET_CHAT_INPUT_USERS_QUERY, { stateId }

  resetSelectedIndex stateId


###*
 * Action to set selected index of chat input users
 *
 * @param {string} stateId
 * @param {number} index
###
setSelectedIndex = (stateId, index) ->

  { SET_CHAT_INPUT_USERS_SELECTED_INDEX } = actionTypes
  dispatch SET_CHAT_INPUT_USERS_SELECTED_INDEX, { stateId, index }


###*
 * Action to increment users selected index
 *
 * @param {string} stateId
###
moveToNextIndex = (stateId) ->

  { MOVE_TO_NEXT_CHAT_INPUT_USERS_INDEX } = actionTypes
  dispatch MOVE_TO_NEXT_CHAT_INPUT_USERS_INDEX, { stateId }


###*
 * Action to decrement users selected index
 *
 * @param {string} stateId
###
moveToPrevIndex = (stateId) ->

  { MOVE_TO_PREV_CHAT_INPUT_USERS_INDEX } = actionTypes
  dispatch MOVE_TO_PREV_CHAT_INPUT_USERS_INDEX, { stateId }


###*
 * Action to reset users selected index
 *
 * @param {string} stateId
###
resetSelectedIndex = (stateId) ->

  { RESET_CHAT_INPUT_USERS_SELECTED_INDEX } = actionTypes
  dispatch RESET_CHAT_INPUT_USERS_SELECTED_INDEX, { stateId }


###*
 * Action to set visibility of chat input users
 *
 * @param {string} stateId
 * @param {bool} visible
###
setVisibility = (stateId, visible) ->

  { SET_CHAT_INPUT_USERS_VISIBILITY } = actionTypes
  dispatch SET_CHAT_INPUT_USERS_VISIBILITY, { stateId, visible }


setChannelParticipantsInputQuery = (query) ->

  if query
    { SET_PARTICIPANT_USERS_QUERY } = actionTypes
    dispatch SET_PARTICIPANT_USERS_QUERY, { query }
    resetChannelParticipantsSelectedIndex()
    appActions.user.searchAccounts query

  else
    unsetChannelParticipantsInputQuery()

###*
 * Action to increment users selected index
###
moveToNextChannelParticipantIndex = ->

  { MOVE_TO_NEXT_CHANNEL_PARTICIPANT_INDEX } = actionTypes
  dispatch MOVE_TO_NEXT_CHANNEL_PARTICIPANT_INDEX


###*
 * Action to decrement users selected index
###
moveToPrevChannelParticipantIndex = ->

  { MOVE_TO_PREV_CHANNEL_PARTICIPANT_INDEX } = actionTypes
  dispatch MOVE_TO_PREV_CHANNEL_PARTICIPANT_INDEX


module.exports = {
  setQuery
  unsetQuery
  setSelectedIndex
  moveToNextIndex
  moveToPrevIndex
  resetSelectedIndex
  setVisibility
  setChannelParticipantsInputQuery
  moveToNextChannelParticipantIndex
  moveToPrevChannelParticipantIndex
}

{'fraction_non_alphanumeric': 0.08772215881297897, 'fraction_numerical': 0.0, 'mean_word_length': 4.663896583564173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, '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': '3517590', 'n_tokens_mistral': 2041, 'n_tokens_neox': 1980, 'n_words': 462}