<commit_before>'use babel';

import d from './CasefileDispatcher';
import { computePegLine } from '../bookmarks';

const makeTypes = (...nameLists) => {
  var result = {};
  for (nameList of nameLists) {
    for (name of nameList.split(/\s+/)) {
      result[name] = name;
    }
  }
  return result;
}

export const types = makeTypes(
  "SET_STATE CLEAR_BOOKMARKS ADD_BOOKMARK MOVE_BOOKMARK EDIT_NOTES DELETE_BOOKMARK"
);

const Actions = {
  setState(newState) {
    d.dispatch({
      type: types.SET_STATE,
      newState
    });
  },
  
  clearBookmarks() {
    d.dispatch({type: types.CLEAR_BOOKMARKS});
  },
  
  addBookmark(file, line, markText, notes) {
    const markInfo = {file, line, markText, notes};
    computePegLine(file, line).then(function(peg) {
      if (peg.commit) {
        markInfo.peg = peg;
      }
    }).catch(function() {
    }).then(function() {
      d.dispatch({
        type: types.ADD_BOOKMARK,
        markInfo
      });
    })
  },
  
  moveBookmark(itemPath, newParentPath, beforeItemId) {
    d.dispatch({
      type: types.MOVE_BOOKMARK,
      itemPath,
      newParentPath,
      beforeItemId
    });
  },
  
  editNotes(itemId, notes) {
    d.dispatch({
      type: types.EDIT_NOTES,
      itemId,
      notes
    });
  },
  
  // itemPath is an Array of bookmark IDs
  deleteBookmark(itemPath) {
    d.dispatch({
      type: types.DELETE_BOOKMARK,
      itemPath
    });
  }
}

export default Actions;
<commit_msg>Allow specifying children when adding a bookmark<commit_after>'use babel';

import d from './CasefileDispatcher';
import { computePegLine } from '../bookmarks';

const makeTypes = (...nameLists) => {
  var result = {};
  for (nameList of nameLists) {
    for (name of nameList.split(/\s+/)) {
      result[name] = name;
    }
  }
  return result;
}

export const types = makeTypes(
  "SET_STATE CLEAR_BOOKMARKS ADD_BOOKMARK MOVE_BOOKMARK EDIT_NOTES DELETE_BOOKMARK"
);

const Actions = {
  setState(newState) {
    d.dispatch({
      type: types.SET_STATE,
      newState
    });
  },
  
  clearBookmarks() {
    d.dispatch({type: types.CLEAR_BOOKMARKS});
  },
  
  addBookmark(file, line, markText, notes, children=[]) {
    const markInfo = {file, line, markText, notes, children};
    computePegLine(file, line).then(function(peg) {
      if (peg.commit) {
        markInfo.peg = peg;
      }
    }).catch(function() {
    }).then(function() {
      d.dispatch({
        type: types.ADD_BOOKMARK,
        markInfo
      });
    })
  },
  
  moveBookmark(itemPath, newParentPath, beforeItemId) {
    d.dispatch({
      type: types.MOVE_BOOKMARK,
      itemPath,
      newParentPath,
      beforeItemId
    });
  },
  
  editNotes(itemId, notes) {
    d.dispatch({
      type: types.EDIT_NOTES,
      itemId,
      notes
    });
  },
  
  // itemPath is an Array of bookmark IDs
  deleteBookmark(itemPath) {
    d.dispatch({
      type: types.DELETE_BOOKMARK,
      itemPath
    });
  }
}

export default Actions;

{'fraction_non_alphanumeric': 0.132907133243607, 'fraction_numerical': 0.0, 'mean_word_length': 2.5435041716328963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5600821', 'n_tokens_mistral': 1042, 'n_tokens_neox': 1020, 'n_words': 208}