<commit_before>'use strict';

import db from '../db';
import { fetchDocs } from './docs';

export function fetchConfig(config) {
  return db.get(config).then(result => {
    return {
      type: 'CONFIG',
      doc: result
    };
  }).catch(err => {
    if (err.name === 'not_found') {
      return {
        type: 'CONFIG_DEFAULT'
      };
    } else {
      throw err;
    }
  });
}

export function receiveConfig(doc) {
  return {
    type: 'CONFIG',
    doc: doc
  };
}

export function toggleDrawer() {
  return {
    type: 'TOGGLE_DRAWER'
  };
}

export function toInit() {
  return dispatch => fetchConfig('dictum_config').then(
    conf => {
      dispatch(conf);
      dispatch(fetchDocs());
    });
}<commit_msg>sending the first doc to the editor on page load<commit_after>'use strict';

import db from '../db';
import { fetchDocs } from './docs';
import { toEditor } from './editor';

export function fetchConfig(config) {
  return db.get(config).then(result => {
    return {
      type: 'CONFIG',
      doc: result
    };
  }).catch(err => {
    if (err.name === 'not_found') {
      return {
        type: 'CONFIG_DEFAULT'
      };
    } else {
      throw err;
    }
  });
}

export function receiveConfig(doc) {
  return {
    type: 'CONFIG',
    doc: doc
  };
}

export function toggleDrawer() {
  return {
    type: 'TOGGLE_DRAWER'
  };
}

export function toInit() {
  return (dispatch, state) => dispatch(
    fetchConfig('dictum_config')
  ).then(
    () => dispatch(fetchDocs())
  ).then(
    () => dispatch(toEditor(state().docs[0]))
  );
}
{'fraction_non_alphanumeric': 0.163787587971849, 'fraction_numerical': 0.0006397952655150352, 'mean_word_length': 2.612009237875289, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '4110676', 'n_tokens_mistral': 519, 'n_tokens_neox': 517, 'n_words': 122}