<commit_before>import Store from 'electron-store';
import environment from '../../../../common/environment';

const store = new Store();

const networkForLocalStorage = String(environment.NETWORK);
const storageKeys = {
  USER_LOCALE: networkForLocalStorage + '-USER-LOCALE',
  TERMS_OF_USE_ACCEPTANCE: networkForLocalStorage + '-TERMS-OF-USE-ACCEPTANCE',
  THEME: networkForLocalStorage + '-THEME',
  DATA_LAYER_MIGRATION_ACCEPTANCE: networkForLocalStorage + '-DATA-LAYER-MIGRATION-ACCEPTANCE',
};

/**
 * This api layer provides access to the electron local storage
 * for user settings that are not synced with any coin backend.
 */

export default class LocalStorageApi {

  getUserLocale = () => new Promise((resolve, reject) => {
    try {
      const locale = store.get(storageKeys.USER_LOCALE);
      if (!locale) return resolve('');
      resolve(locale);
    } catch (error) {
      return reject(error);
    }
  });

  setUserLocale = (locale: string) => new Promise((resolve, reject) => {
    try {
      store.set(storageKeys.USER_LOCALE, locale);
      resolve();
    } catch (error) {
      return reject(error);
    }
  });

  unsetUserLocale = () => new Promise((resolve) => {
    try {
      store.delete(storageKeys.USER_LOCALE);
      resolve();
    } catch (error) {} // eslint-disable-line
  });

  getTermsOfUseAcceptance = () => new Promise((resolve, reject) => {
    try {
      const accepted = store.get(storageKeys.TERMS_OF_USE_ACCEPTANCE);
      if (!accepted) return resolve(false);
      resolve(accepted);
    } catch (error) {
      return reject(error);
    }
  });

  setTermsOfUseAcceptance = () => new Promise((resolve, reject) => {
    try {
      store.set(storageKeys.TERMS_OF_USE_ACCEPTANCE, true);
      resolve();
    } catch (error) {
      return reject(error);
    }
  });

  unsetTermsOfUseAcceptance = () => new Promise((resolve) => {
    try {
      store.delete(storageKeys.TERMS_OF_USE_ACCEPTANCE);
      resolve();
    } catch (error) {} // eslint-disable-line
  });

  getUserTheme = () => new Promise((resolve, reject) => {
    try {
      const theme = store.get(storageKeys.THEME);
      if (!theme) return resolve('');
      resolve(theme);
    } catch (error) {
      return reject(error);
    }
  });

  setUserTheme = (theme: string) => new Promise((resolve, reject) => {
    try {
      store.set(storageKeys.THEME, theme);
      resolve();
    } catch (error) {
      return reject(error);
    }
  });

  unsetUserTheme = () => new Promise((resolve) => {
    try {
      store.delete(storageKeys.THEME);
      resolve();
    } catch (error) {} // eslint-disable-line
  });

  getDataLayerMigrationAcceptance = () => new Promise((resolve, reject) => {
    try {
      const accepted = store.get(storageKeys.DATA_LAYER_MIGRATION_ACCEPTANCE);
      if (!accepted) return resolve(false);
      resolve(accepted);
    } catch (error) {
      return reject(error);
    }
  });

  setDataLayerMigrationAcceptance = () => new Promise((resolve, reject) => {
    try {
      store.set(storageKeys.DATA_LAYER_MIGRATION_ACCEPTANCE, true);
      resolve();
    } catch (error) {
      return reject(error);
    }
  });

  unsetDataLayerMigrationAcceptance = () => new Promise((resolve) => {
    try {
      store.delete(storageKeys.DATA_LAYER_MIGRATION_ACCEPTANCE);
      resolve();
    } catch (error) {} // eslint-disable-line
  });

  async reset() {<commit_msg>[DDW-262] Adds needed environment data as params to LocalStorageApi constructor<commit_after>import Store from 'electron-store';

const store = new Store();

/**
 * This api layer provides access to the electron local storage
 * for user settings that are not synced with any coin backend.
 */

export default class LocalStorageApi {
  constructor(NETWORK: string) {
    this.storageKeys = {
      USER_LOCALE: `${NETWORK}-USER-LOCALE`,
      TERMS_OF_USE_ACCEPTANCE: `${NETWORK}-TERMS-OF-USE-ACCEPTANCE`,
      THEME: `${NETWORK}-THEME`,
      DATA_LAYER_MIGRATION_ACCEPTANCE: `${NETWORK}-DATA-LAYER-MIGRATION-ACCEPTANCE`,
    };
  }

  getUserLocale = () => new Promise((resolve, reject) => {
    try {
      const locale = store.get(this.storageKeys.USER_LOCALE);
      if (!locale) return resolve('');
      resolve(locale);
    } catch (error) {
      return reject(error);
    }
  });

  setUserLocale = (locale: string) => new Promise((resolve, reject) => {
    try {
      store.set(this.storageKeys.USER_LOCALE, locale);
      resolve();
    } catch (error) {
      return reject(error);
    }
  });

  unsetUserLocale = () => new Promise((resolve) => {
    try {
      store.delete(this.storageKeys.USER_LOCALE);
      resolve();
    } catch (error) {} // eslint-disable-line
  });

  getTermsOfUseAcceptance = () => new Promise((resolve, reject) => {
    try {
      const accepted = store.get(this.storageKeys.TERMS_OF_USE_ACCEPTANCE);
      if (!accepted) return resolve(false);
      resolve(accepted);
    } catch (error) {
      return reject(error);
    }
  });

  setTermsOfUseAcceptance = () => new Promise((resolve, reject) => {
    try {
      store.set(this.storageKeys.TERMS_OF_USE_ACCEPTANCE, true);
      resolve();
    } catch (error) {
      return reject(error);
    }
  });

  unsetTermsOfUseAcceptance = () => new Promise((resolve) => {
    try {
      store.delete(this.storageKeys.TERMS_OF_USE_ACCEPTANCE);
      resolve();
    } catch (error) {} // eslint-disable-line
  });

  getUserTheme = () => new Promise((resolve, reject) => {
    try {
      const theme = store.get(this.storageKeys.THEME);
      if (!theme) return resolve('');
      resolve(theme);
    } catch (error) {
      return reject(error);
    }
  });

  setUserTheme = (theme: string) => new Promise((resolve, reject) => {
    try {
      store.set(this.storageKeys.THEME, theme);
      resolve();
    } catch (error) {
      return reject(error);
    }
  });

  unsetUserTheme = () => new Promise((resolve) => {
    try {
      store.delete(this.storageKeys.THEME);
      resolve();
    } catch (error) {} // eslint-disable-line
  });

  getDataLayerMigrationAcceptance = () => new Promise((resolve, reject) => {
    try {
      const accepted = store.get(this.storageKeys.DATA_LAYER_MIGRATION_ACCEPTANCE);
      if (!accepted) return resolve(false);
      resolve(accepted);
    } catch (error) {
      return reject(error);
    }
  });

  setDataLayerMigrationAcceptance = () => new Promise((resolve, reject) => {
    try {
      store.set(this.storageKeys.DATA_LAYER_MIGRATION_ACCEPTANCE, true);
      resolve();
    } catch (error) {
      return reject(error);
    }
  });

  unsetDataLayerMigrationAcceptance = () => new Promise((resolve) => {
    try {
      store.delete(this.storageKeys.DATA_LAYER_MIGRATION_ACCEPTANCE);
      resolve();
    } catch (error) {} // eslint-disable-line
  });

  async reset() {
{'fraction_non_alphanumeric': 0.14776883686905634, 'fraction_numerical': 0.0004389173372348208, 'mean_word_length': 3.016451233842538, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 51, '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': '4143993', 'n_tokens_mistral': 2147, 'n_tokens_neox': 2130, 'n_words': 423}