<commit_before>import { remote } from 'electron';
import LocalStorageSync from '../utils/backboneLocalStorage';
import { Model } from 'backbone';
import is from 'is_js';
import { feeLevels } from '../utils/fees';
import app from '../app';

export default class extends Model {
  localStorage() {
    return new LocalStorageSync('__localSettings');
  }

  sync(...args) {
    return LocalStorageSync.sync.apply(this, args);
  }

  defaults() {
    return {
      windowControlStyle: remote.process.platform === 'darwin' ? 'mac' : 'win',
      showAdvancedVisualEffects: true,
      saveTransactionMetadata: true,
      defaultTransactionFee: 'PRIORITY',
      language: 'en-US',
      listingsGridViewType: 'grid',
      bitcoinUnit: 'BTC',
      searchProvider: 'https://search.ob1.io/search/listings',
      dontShowTorExternalLinkWarning: false,
    };
  }

  get controlStyles() {
    return ['mac', 'win'];
  }

  get viewStyles() {
    return ['list', 'grid'];
  }

  get bitcoinUnits() {
    return ['BTC', 'MBTC', 'UBTC', 'SATOSHI'];
  }

  validate(attrs) {
    const errObj = {};
    const addError = (fieldName, error) => {
      errObj[fieldName] = errObj[fieldName] || [];
      errObj[fieldName].push(error);
    };

    if (!this.controlStyles.includes(attrs.windowControlStyle)) {
      addError('windowControlStyle', `Please provide one of ${this.controlStyles}.`);
    }

    if (!this.viewStyles.includes(attrs.listingsGridViewType)) {
      addError(`ListingGrideViewType needs to be one of ${this.viewStyles}.`);
    }

    if (!feeLevels.includes(attrs.defaultTransactionFee)) {
      addError('defaultTransactionFee', `The fee level must be one of ${feeLevels.join(', ')}`);
    }

    if (!this.bitcoinUnits.includes(attrs.bitcoinUnit)) {
      addError(`bitcoinUnit needs to be one of ${this.bitcoinUnits}.`);
    }

    if (is.not.url(attrs.searchProvider)) {
      addError('searchProvider', app.polyglot.t('localSettingsModelErrors.searchProvider'));
    }

    if (typeof attrs.dontShowTorExternalLinkWarning !== 'boolean') {
      addError('dontShowTorExternalLinkWarning',
        'dontShowTorExternalLinkWarning must be provided as a boolean.');
    }

    if (Object.keys(errObj).length && errObj) return errObj;

    return undefined;
  }
}
<commit_msg>Set default fee level to normal.<commit_after>import { remote } from 'electron';
import LocalStorageSync from '../utils/backboneLocalStorage';
import { Model } from 'backbone';
import is from 'is_js';
import { feeLevels } from '../utils/fees';
import app from '../app';

export default class extends Model {
  localStorage() {
    return new LocalStorageSync('__localSettings');
  }

  sync(...args) {
    return LocalStorageSync.sync.apply(this, args);
  }

  defaults() {
    return {
      windowControlStyle: remote.process.platform === 'darwin' ? 'mac' : 'win',
      showAdvancedVisualEffects: true,
      saveTransactionMetadata: true,
      defaultTransactionFee: 'NORMAL',
      language: 'en-US',
      listingsGridViewType: 'grid',
      bitcoinUnit: 'BTC',
      searchProvider: 'https://search.ob1.io/search/listings',
      dontShowTorExternalLinkWarning: false,
    };
  }

  get controlStyles() {
    return ['mac', 'win'];
  }

  get viewStyles() {
    return ['list', 'grid'];
  }

  get bitcoinUnits() {
    return ['BTC', 'MBTC', 'UBTC', 'SATOSHI'];
  }

  validate(attrs) {
    const errObj = {};
    const addError = (fieldName, error) => {
      errObj[fieldName] = errObj[fieldName] || [];
      errObj[fieldName].push(error);
    };

    if (!this.controlStyles.includes(attrs.windowControlStyle)) {
      addError('windowControlStyle', `Please provide one of ${this.controlStyles}.`);
    }

    if (!this.viewStyles.includes(attrs.listingsGridViewType)) {
      addError(`ListingGrideViewType needs to be one of ${this.viewStyles}.`);
    }

    if (!feeLevels.includes(attrs.defaultTransactionFee)) {
      addError('defaultTransactionFee', `The fee level must be one of ${feeLevels.join(', ')}`);
    }

    if (!this.bitcoinUnits.includes(attrs.bitcoinUnit)) {
      addError(`bitcoinUnit needs to be one of ${this.bitcoinUnits}.`);
    }

    if (is.not.url(attrs.searchProvider)) {
      addError('searchProvider', app.polyglot.t('localSettingsModelErrors.searchProvider'));
    }

    if (typeof attrs.dontShowTorExternalLinkWarning !== 'boolean') {
      addError('dontShowTorExternalLinkWarning',
        'dontShowTorExternalLinkWarning must be provided as a boolean.');
    }

    if (Object.keys(errObj).length && errObj) return errObj;

    return undefined;
  }
}

{'fraction_non_alphanumeric': 0.14534757027674874, 'fraction_numerical': 0.00043582479843103073, 'mean_word_length': 3.549058473736373, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '2329812', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1410, 'n_words': 299}