<commit_before>export const ADD_FLAG_BEGIN = `ADD_FLAG_BEGIN`;
function addFlagBegin(activity) {
  return {
    type: ADD_FLAG_BEGIN,
    payload: {
      activity
    }
  };
}

export const ADD_FLAG = `ADD_FLAG`;
function addFlagSuccess(activity, flag) {
  return {
    type: ADD_FLAG,
    payload: {
      activity,
      flag
    }
  };
}

function addFlagError(activity, error) {
  return {
    type: ADD_FLAG,
    payload: {
      activity,
      error
    },
    error: true
  };
}

export const FLAGS_REQUEST_BEGIN = `FLAGS_REQUEST_BEGIN`;
function flagsRequestBegin() {
  return {
    type: FLAGS_REQUEST_BEGIN
  };
}

export const FLAGS_REQUEST = `FLAGS_REQUEST`;
function flagsRequestSuccess(flags) {
  return {
    type: FLAGS_REQUEST,
    payload: {
      flags
    }
  };
}

function flagsRequestError(error) {
  return {
    type: FLAGS_REQUEST,
    payload: error,
    error: true
  };
}

export const REMOVE_FLAG = `REMOVE_FLAG`;
function removeFlagBegin(flag) {
  return {
    type: REMOVE_FLAG,
    payload: {
      flag
    }
  };
}

function removeFlagError(error, flag) {
  return {
    type: REMOVE_FLAG,
    payload: {
      error,
      flag
    },
    error: true
  };
}



/**
 * Fetches all of the current user's flags
 *
 * @param {any} spark
 * @returns {function}
 */
export function fetchFlags(spark) {
  return (dispatch) => {
    dispatch(flagsRequestBegin());
    return spark.flag.list()
      .then((flags) =>
        dispatch(flagsRequestSuccess(flags))
      )
      .catch((error) =>
        dispatch(flagsRequestError(error))
      );
  };
}

/**
 * Flags a given activity. Updates state immediately then
 * adds flag details given from api
 *
 * @param {any} activity
 * @param {any} spark
 * @returns {function}
 */
export function flagActivity(activity, spark) {
  return (dispatch) => {<commit_msg>fix(widget-chat): remove extra spaces failing eslint<commit_after>export const ADD_FLAG_BEGIN = `ADD_FLAG_BEGIN`;
function addFlagBegin(activity) {
  return {
    type: ADD_FLAG_BEGIN,
    payload: {
      activity
    }
  };
}

export const ADD_FLAG = `ADD_FLAG`;
function addFlagSuccess(activity, flag) {
  return {
    type: ADD_FLAG,
    payload: {
      activity,
      flag
    }
  };
}

function addFlagError(activity, error) {
  return {
    type: ADD_FLAG,
    payload: {
      activity,
      error
    },
    error: true
  };
}

export const FLAGS_REQUEST_BEGIN = `FLAGS_REQUEST_BEGIN`;
function flagsRequestBegin() {
  return {
    type: FLAGS_REQUEST_BEGIN
  };
}

export const FLAGS_REQUEST = `FLAGS_REQUEST`;
function flagsRequestSuccess(flags) {
  return {
    type: FLAGS_REQUEST,
    payload: {
      flags
    }
  };
}

function flagsRequestError(error) {
  return {
    type: FLAGS_REQUEST,
    payload: error,
    error: true
  };
}

export const REMOVE_FLAG = `REMOVE_FLAG`;
function removeFlagBegin(flag) {
  return {
    type: REMOVE_FLAG,
    payload: {
      flag
    }
  };
}

function removeFlagError(error, flag) {
  return {
    type: REMOVE_FLAG,
    payload: {
      error,
      flag
    },
    error: true
  };
}

/**
 * Fetches all of the current user's flags
 *
 * @param {any} spark
 * @returns {function}
 */
export function fetchFlags(spark) {
  return (dispatch) => {
    dispatch(flagsRequestBegin());
    return spark.flag.list()
      .then((flags) =>
        dispatch(flagsRequestSuccess(flags))
      )
      .catch((error) =>
        dispatch(flagsRequestError(error))
      );
  };
}

/**
 * Flags a given activity. Updates state immediately then
 * adds flag details given from api
 *
 * @param {any} activity
 * @param {any} spark
 * @returns {function}
 */
export function flagActivity(activity, spark) {
  return (dispatch) => {
{'fraction_non_alphanumeric': 0.11609782316581564, 'fraction_numerical': 0.0, 'mean_word_length': 2.8569948186528498, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '1776154', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1201, 'n_words': 281}