<commit_before>import syncClient from '../db/sync_client';
import { DELETE_BOOKMARK, DELETE_FOLDER } from '../constants';

export function deleteBookmark(id) {
  return (dispatch) => {
    syncClient
      .bookmarks
      .delete(id)
      .then(() => {
        dispatch({
          type: DELETE_BOOKMARK,
          payload: id,
        });
      })
      .catch((e) => {
        console.log(e);
      });
  };
}

export function deleteFolder(id) {
  return (dispatch) => {
    syncClient
      .folders
      .delete(id)
      .then(() => {
        dispatch({
          type: DELETE_FOLDER,
          payload: id,
        });
      })
      .catch((e) => {
        console.log(e);
      });
  };
}<commit_msg>Remove all children of a folder when it is deleted<commit_after>import syncClient from '../db/sync_client';
import { DELETE_BOOKMARK, DELETE_FOLDER } from '../constants';

export function deleteBookmark(id) {
  return (dispatch) => {
    syncClient
      .bookmarks
      .delete(id)
      .then(() => {
        dispatch({
          type: DELETE_BOOKMARK,
          payload: id,
        });
      })
      .catch((e) => {
        console.log(e);
      });
  };
}

export function deleteFolder(id) {
  return (dispatch) => {
    syncClient
        .transaction('rw', syncClient.folders, syncClient.bookmarks, () => {
          syncClient.folders.where('parentID').equals(id).delete();
          syncClient.bookmarks.where('parentID').equals(id).delete();
          syncClient.folders.delete(id);
        })
        .then(() => {
          dispatch({
            type: DELETE_FOLDER,
            payload: id,
          });
        })
        .catch((e) => {
          console.log(e);
        });
  };
}
{'fraction_non_alphanumeric': 0.15721800116890708, 'fraction_numerical': 0.0, 'mean_word_length': 1.8391376451077943, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '3804659', 'n_tokens_mistral': 527, 'n_tokens_neox': 527, 'n_words': 95}