<commit_before>'use strict';

var ActorAppDispatcher = require('../dispatcher/ActorAppDispatcher');
var ActorAppConstants = require('../constants/ActorAppConstants');
var ActorClient = require('../utils/ActorClient');
var ActionTypes = ActorAppConstants.ActionTypes;

var ContactActionCreators = require('../actions/ContactActionCreators');
var LoginStore = require('../stores/LoginStore');

var EventEmitter = require('events').EventEmitter;
var assign = require('object-assign');

var CHANGE_EVENT = 'change';

var _contacts = [];
var _isContactsOpen = false;


var ContactStore = assign({}, EventEmitter.prototype, {
  emitChange: function() {
    this.emit(CHANGE_EVENT);
  },

  addChangeListener: function(callback) {
    this.on(CHANGE_EVENT, callback)
  },

  removeChangeListener: function(callback) {
    this.removeListener(CHANGE_EVENT, callback)
  },

  getContacts: function() {
    return(_contacts);
  },

  isContactsOpen: function() {
    return(_isContactsOpen);
  }
});

var setContacts = function(contacts) {
  console.warn(contacts);
  // We need setTimeout here because bindDialogs dispatches event but bindDialogs itseld is called in the middle of dispatch (DialogStore)
  setTimeout(function() {
    ContactActionCreators.setContacts(contacts);
  }, 0);
};

ContactStore.dispatchToken = ActorAppDispatcher.register(function(action) {
  console.warn(action);
  switch(action.type) {
    case ActionTypes.SET_LOGGED_IN:
      ActorAppDispatcher.waitFor([LoginStore.dispatchToken]);
      ActorClient.bindContacts(setContacts);
      break;

    case ActionTypes.CONTACT_LIST_SHOW:
      _isContactsOpen = true;
      ContactStore.emitChange();
      break;

    case ActionTypes.CONTACT_LIST_HIDE:
      _isContactsOpen = false;
      ContactStore.emitChange();
      break;

    case ActionTypes.DIALOGS_CHANGED:
      _contacts = action.contacts;
      ContactStore.emitChange();
      break;

    case ActionTypes.CONTACT_ADD:
      ActorClient.addContact(action.uid);
      ContactStore.emitChange();
      break;

    case ActionTypes.CONTACT_REMOVE:
      ActorClient.removeContact(action.uid);
      ContactStore.emitChange();
      break;

    default:
  }
});

module.exports = ContactStore;
<commit_msg>fix(web): change wrong action type;<commit_after>'use strict';

var ActorAppDispatcher = require('../dispatcher/ActorAppDispatcher');
var ActorAppConstants = require('../constants/ActorAppConstants');
var ActorClient = require('../utils/ActorClient');
var ActionTypes = ActorAppConstants.ActionTypes;

var ContactActionCreators = require('../actions/ContactActionCreators');
var LoginStore = require('../stores/LoginStore');

var EventEmitter = require('events').EventEmitter;
var assign = require('object-assign');

var CHANGE_EVENT = 'change';

var _contacts = [];
var _isContactsOpen = false;


var ContactStore = assign({}, EventEmitter.prototype, {
  emitChange: function() {
    this.emit(CHANGE_EVENT);
  },

  addChangeListener: function(callback) {
    this.on(CHANGE_EVENT, callback)
  },

  removeChangeListener: function(callback) {
    this.removeListener(CHANGE_EVENT, callback)
  },

  getContacts: function() {
    return(_contacts);
  },

  isContactsOpen: function() {
    return(_isContactsOpen);
  }
});

var setContacts = function(contacts) {
  setTimeout(function() {
    ContactActionCreators.setContacts(contacts);
  }, 0);
};

ContactStore.dispatchToken = ActorAppDispatcher.register(function(action) {
  console.warn(action);
  switch(action.type) {
    case ActionTypes.SET_LOGGED_IN:
      ActorAppDispatcher.waitFor([LoginStore.dispatchToken]);
      ActorClient.bindContacts(setContacts);
      break;

    case ActionTypes.CONTACT_LIST_SHOW:
      _isContactsOpen = true;
      ContactStore.emitChange();
      break;

    case ActionTypes.CONTACT_LIST_HIDE:
      _isContactsOpen = false;
      ContactStore.emitChange();
      break;

    case ActionTypes.CONTACT_LIST_CHANGED:
      _contacts = action.contacts;
      ContactStore.emitChange();
      break;

    case ActionTypes.CONTACT_ADD:
      ActorClient.addContact(action.uid);
      ContactStore.emitChange();
      break;

    case ActionTypes.CONTACT_REMOVE:
      ActorClient.removeContact(action.uid);
      ContactStore.emitChange();
      break;

    default:
  }
});

module.exports = ContactStore;

{'fraction_non_alphanumeric': 0.1172127365020766, 'fraction_numerical': 0.00046146746654360867, 'mean_word_length': 4.17921146953405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7240113', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1287, 'n_words': 226}