<commit_before>import { ADD_REPO, ADDING_REPO, ADDING_REPO_END,
         UPDATE_REPO,
         DELETE_REPO,
         REORDER_REPO,
         RELOADING, RELOADING_ALL_REPOS, RELOADING_ALL_REPOS_END,
         ADD_GROUP, REORDER_GROUP, DELETE_GROUP, START_EDITING_GROUP, EDIT_GROUP,
         MESSAGE } from '../constants/ActionTypes';

import { resolve } from 'path';
import { ActionCreatorsMapObject } from 'redux';

import gitRepos from '../helpers/GitRepos';
import * as electron from 'electron';

const actions: ActionCreatorsMapObject = {
  addRepos: () => {
    return (dispatch, getState) => {
      let dirs = electron.remote.dialog.showOpenDialog({
        properties: ['openDirectory', 'multiSelections']
      });

      dispatch({ type: ADDING_REPO });

      gitRepos.searchRepos(
        dirs,
        (gitDir) => { // steps
          const newRepoDit = resolve(gitDir, '..');
          const repoByDir = getState().repos.filter(s => s.dir === newRepoDit);
          if (repoByDir.length === 0) {
            dispatch(this.default.addRepo(newRepoDit));
          } else {
            dispatch(this.default.message(`Repo '${newRepoDit}' is already there ;-)`));
          }
        },
        (err, gitDirs) => {
          dispatch({ type: ADDING_REPO_END });
        });
    };
  },

  reloadAllRepos: () => {
     return (dispatch, getState) => {
      dispatch({ type: RELOADING_ALL_REPOS });

      getState().repos.map((groups, gid) => {
        groups.repos.map((r, rid) => {
          // console.log(r, r.dir, id);
          setTimeout(() => {
            this.default.reloadRepo(r.dir)(dispatch);
          }, 50 * (gid + rid));
        });
      });

      setTimeout(() => {
        dispatch({ type: RELOADING_ALL_REPOS_END });
      }, 1000);
     };
  },

  addRepo: (dir) => {
    return { type: ADD_REPO, dir };
  },

  addGroup: () => {
    return { type: ADD_GROUP };
  },

  reorderRepo: (params) => {
    return { type: REORDER_REPO, params };
  },<commit_msg>prettify reload all action, one by one after 100 ms delay<commit_after>import { ADD_REPO, ADDING_REPO, ADDING_REPO_END,
         UPDATE_REPO,
         DELETE_REPO,
         REORDER_REPO,
         RELOADING, RELOADING_ALL_REPOS, RELOADING_ALL_REPOS_END,
         ADD_GROUP, REORDER_GROUP, DELETE_GROUP, START_EDITING_GROUP, EDIT_GROUP,
         MESSAGE } from '../constants/ActionTypes';

import { resolve } from 'path';
import { ActionCreatorsMapObject } from 'redux';

import gitRepos from '../helpers/GitRepos';
import * as electron from 'electron';

const actions: ActionCreatorsMapObject = {
  addRepos: () => {
    return (dispatch, getState) => {
      let dirs = electron.remote.dialog.showOpenDialog({
        properties: ['openDirectory', 'multiSelections']
      });

      dispatch({ type: ADDING_REPO });

      gitRepos.searchRepos(
        dirs,
        (gitDir) => { // steps
          const newRepoDit = resolve(gitDir, '..');
          const repoByDir = getState().repos.filter(s => s.dir === newRepoDit);
          if (repoByDir.length === 0) {
            dispatch(this.default.addRepo(newRepoDit));
          } else {
            dispatch(this.default.message(`Repo '${newRepoDit}' is already there ;-)`));
          }
        },
        (err, gitDirs) => {
          dispatch({ type: ADDING_REPO_END });
        });
    };
  },

  reloadAllRepos: () => {
     return (dispatch, getState) => {
      dispatch({ type: RELOADING_ALL_REPOS });

      let i = 0;
      getState().repos.map((groups, gid) => {
        groups.repos.map((r, rid) => {
          // console.log(r, r.dir, id);
          setTimeout(() => {
            this.default.reloadRepo(r.dir)(dispatch);
          }, 100 * i);
          i++;
        });
      });

      setTimeout(() => {
        dispatch({ type: RELOADING_ALL_REPOS_END });
      }, 1000);
     };
  },

  addRepo: (dir) => {
    return { type: ADD_REPO, dir };
  },

  addGroup: () => {
    return { type: ADD_GROUP };
  },

  reorderRepo: (params) => {
    return { type: REORDER_REPO, params };
  },
{'fraction_non_alphanumeric': 0.15219005196733482, 'fraction_numerical': 0.0047018064835436775, 'mean_word_length': 2.296900489396411, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, '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': '2931163', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1315, 'n_words': 249}