<commit_before>// @flow
import { getCfg, writeCfg } from "../config.js";
export const SETTINGS_SAVE = "SETTINGS_SAVE";
export const SETTINGS_CHANGED = "SETTINGS_CHANGED";
export const SETTINGS_UNCHANGED = "SETTINGS_UNCHANGED";

export function saveSettings(settings) {
  return {
    settings,
    type: SETTINGS_SAVE
  };
}
export function updateStateSettingsChanged(settings) {
  return (dispatch, getState) => {
    var cfg = getCfg();
    const { tempSettings, currentSettings } = getState().settings;
    if ((settings.currencyDisplay !== tempSettings.currencyDisplay) ||
	(settings.network !== tempSettings.network)){
      if (settings.currencyDisplay !== currentSettings.currencyDisplay) {
        cfg.set("currency_display", settings.currencyDisplay);
        dispatch({ tempSettings: settings, type: SETTINGS_CHANGED});
      } else if (settings.network !== currentSettings.network) {
        cfg.set("network", settings.network);
        dispatch({ tempSettings: settings, type: SETTINGS_CHANGED});
      } else {
        dispatch({ tempSettings: currentSettings, type: SETTINGS_UNCHANGED});
      }
    }
  };
}

export function updateStateVoteSettingsChanged(settings) {
  return (dispatch, getState) => {
    var cfg = getCfg();
    const { tempSettings, currentSettings } = getState().settings;
    if (settings.enableTicketBuyer !== tempSettings.enableTicketBuyer) {
      cfg.set("enableticketbuyer", settings.enableTicketBuyer);
      dispatch({ tempSettings: settings, type: SETTINGS_CHANGED});<commit_msg>Move setting config update into saveSettings (#674)<commit_after>// @flow
import { getCfg, writeCfg } from "../config.js";
export const SETTINGS_SAVE = "SETTINGS_SAVE";
export const SETTINGS_CHANGED = "SETTINGS_CHANGED";
export const SETTINGS_UNCHANGED = "SETTINGS_UNCHANGED";

export function saveSettings(settings) {
  var cfg = getCfg();
  cfg.set("currency_display", settings.currencyDisplay);
  cfg.set("network", settings.network);
  return {
    settings,
    type: SETTINGS_SAVE
  };
}
export function updateStateSettingsChanged(settings) {
  return (dispatch, getState) => {
    const { tempSettings, currentSettings } = getState().settings;
    if ((settings.currencyDisplay !== tempSettings.currencyDisplay) ||
	(settings.network !== tempSettings.network)){
      if (settings.currencyDisplay !== currentSettings.currencyDisplay) {
        dispatch({ tempSettings: settings, type: SETTINGS_CHANGED});
      } else if (settings.network !== currentSettings.network) {
        dispatch({ tempSettings: settings, type: SETTINGS_CHANGED});
      } else {
        dispatch({ tempSettings: currentSettings, type: SETTINGS_UNCHANGED});
      }
    }
  };
}

export function updateStateVoteSettingsChanged(settings) {
  return (dispatch, getState) => {
    var cfg = getCfg();
    const { tempSettings, currentSettings } = getState().settings;
    if (settings.enableTicketBuyer !== tempSettings.enableTicketBuyer) {
      cfg.set("enableticketbuyer", settings.enableTicketBuyer);
      dispatch({ tempSettings: settings, type: SETTINGS_CHANGED});
{'fraction_non_alphanumeric': 0.12199089134677944, 'fraction_numerical': 0.0009759271307742355, 'mean_word_length': 4.54054054054054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6319353', 'n_tokens_mistral': 889, 'n_tokens_neox': 880, 'n_words': 193}