<commit_before>KodingFluxStore      = require 'app/flux/base/store'
actions              = require '../actions/actiontypes'
toImmutable          = require 'app/util/toImmutable'
immutable            = require 'immutable'
createChannelActions = require 'activity/flux/createchannel/actions/actiontypes'

module.exports = class ChannelsStore extends KodingFluxStore

  @getterPath = 'ChannelsStore'

  getInitialState: -> immutable.Map()

  initialize: ->

    @on actions.LOAD_CHANNEL_SUCCESS, @handleLoadChannelSuccess
    @on actions.LOAD_FOLLOWED_PUBLIC_CHANNEL_SUCCESS, @handleLoadFollowedChannelSuccess
    @on actions.LOAD_FOLLOWED_PRIVATE_CHANNEL_SUCCESS, @handleLoadChannelSuccess
    @on actions.LOAD_POPULAR_CHANNELS_SUCCESS, @handleLoadChannelListSuccess

    @on actions.FOLLOW_CHANNEL_BEGIN, @handleFollowChannelBegin
    @on actions.FOLLOW_CHANNEL_SUCCESS, @handleFollowChannelSuccess
    @on actions.FOLLOW_CHANNEL_FAIL, @handleFollowChannelFail

    @on actions.UNFOLLOW_CHANNEL_BEGIN, @handleUnfollowChannelBegin
    @on actions.UNFOLLOW_CHANNEL_SUCCESS, @handleUnfollowChannelSuccess
    @on actions.UNFOLLOW_CHANNEL_FAIL, @handleUnfollowChannelFail
    @on actions.LEAVE_PRIVATE_CHANNEL_SUCCESS, @handleUnfollowChannelSuccess

    @on actions.ADD_PARTICIPANTS_TO_CHANNEL_BEGIN, @handleAddParticipantsToChannelBegin
    @on actions.ADD_PARTICIPANTS_TO_CHANNEL_FAIL, @handleAddParticipantsToChannelFail

    @on actions.SET_CHANNEL_UNREAD_COUNT, @handleSetUnreadCount

    @on actions.GLANCE_CHANNEL_BEGIN, @handleGlanceChannel
    @on actions.GLANCE_CHANNEL_SUCCESS, @handleGlanceChannel

    @on actions.REMOVE_PARTICIPANT_FROM_CHANNEL, @handleRemoveParticipantFromChannel

    @on createChannelActions.CREATE_PRIVATE_CHANNEL_SUCCESS, @handleLoadChannelSuccess
    @on createChannelActions.CREATE_PUBLIC_CHANNEL_SUCCESS, @handleLoadChannelSuccess

  handleLoadChannelSuccess: (channels, { channel }) ->

    return channels.set channel.id, toImmutable channel


  handleLoadChannelListSuccess: (currentChannels, { channels }) ->

    return currentChannels.withMutations (map) ->
      map.set channel.id, toImmutable channel for channel in  channels
      return map

<commit_msg>Client: Activity: Added Update_Channel_Success event listener to channels store<commit_after>KodingFluxStore      = require 'app/flux/base/store'
actions              = require '../actions/actiontypes'
toImmutable          = require 'app/util/toImmutable'
immutable            = require 'immutable'
createChannelActions = require 'activity/flux/createchannel/actions/actiontypes'

module.exports = class ChannelsStore extends KodingFluxStore

  @getterPath = 'ChannelsStore'

  getInitialState: -> immutable.Map()

  initialize: ->

    @on actions.LOAD_CHANNEL_SUCCESS, @handleLoadChannelSuccess
    @on actions.LOAD_FOLLOWED_PUBLIC_CHANNEL_SUCCESS, @handleLoadFollowedChannelSuccess
    @on actions.LOAD_FOLLOWED_PRIVATE_CHANNEL_SUCCESS, @handleLoadChannelSuccess
    @on actions.LOAD_POPULAR_CHANNELS_SUCCESS, @handleLoadChannelListSuccess

    @on actions.FOLLOW_CHANNEL_BEGIN, @handleFollowChannelBegin
    @on actions.FOLLOW_CHANNEL_SUCCESS, @handleFollowChannelSuccess
    @on actions.FOLLOW_CHANNEL_FAIL, @handleFollowChannelFail

    @on actions.UNFOLLOW_CHANNEL_BEGIN, @handleUnfollowChannelBegin
    @on actions.UNFOLLOW_CHANNEL_SUCCESS, @handleUnfollowChannelSuccess
    @on actions.UNFOLLOW_CHANNEL_FAIL, @handleUnfollowChannelFail
    @on actions.LEAVE_PRIVATE_CHANNEL_SUCCESS, @handleUnfollowChannelSuccess

    @on actions.ADD_PARTICIPANTS_TO_CHANNEL_BEGIN, @handleAddParticipantsToChannelBegin
    @on actions.ADD_PARTICIPANTS_TO_CHANNEL_FAIL, @handleAddParticipantsToChannelFail

    @on actions.SET_CHANNEL_UNREAD_COUNT, @handleSetUnreadCount

    @on actions.GLANCE_CHANNEL_BEGIN, @handleGlanceChannel
    @on actions.GLANCE_CHANNEL_SUCCESS, @handleGlanceChannel

    @on actions.REMOVE_PARTICIPANT_FROM_CHANNEL, @handleRemoveParticipantFromChannel

    @on actions.UPDATE_CHANNEL_SUCCESS, @handleLoadChannelSuccess

    @on createChannelActions.CREATE_PRIVATE_CHANNEL_SUCCESS, @handleLoadChannelSuccess
    @on createChannelActions.CREATE_PUBLIC_CHANNEL_SUCCESS, @handleLoadChannelSuccess

  handleLoadChannelSuccess: (channels, { channel }) ->

    return channels.set channel.id, toImmutable channel


  handleLoadChannelListSuccess: (currentChannels, { channels }) ->

    return currentChannels.withMutations (map) ->
      map.set channel.id, toImmutable channel for channel in  channels
      return map


{'fraction_non_alphanumeric': 0.06709335687486206, 'fraction_numerical': 0.0, 'mean_word_length': 5.704142011834319, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '5895408', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1264, 'n_words': 223}