<commit_before>import { Chrome } from './chrome';

export class Saved {
  static data = [];
  static _fetchedFromStorage = false;

  /**
   * Returns a promise
   */
  static get () {
    return new Promise((resolve, reject) => {
      if (Saved._fetchedFromStorage) {
        resolve(Saved.data);
      }

      Chrome.getSetting('saved')
        .then((results) => {
          if (results.saved) {
            Saved.data = results.saved;
          }

          Saved._fetchedFromStorage = true;

          resolve(Saved.data);
        });
    });
  }

  /**
   * colour should be a hex value
   */
  static add (colour) {
    Saved.data.push(colour);

    Chrome.setSetting('saved', Saved.data);
  }
}<commit_msg>Fix overriding saved colours issue<commit_after>import { Chrome } from './chrome';
import { Colours } from './colours';

export class Saved {
  static data = [];
  static _fetchedFromStorage = false;

  /**
   * Returns a promise
   */
  static get () {
    return new Promise((resolve, reject) => {
      if (Saved._fetchedFromStorage) {
        resolve(Saved.data);
      }

      Chrome.getSetting('saved')
        .then((results) => {
          if (results.saved) {
            Saved.data = results.saved;
          }

          Saved._fetchedFromStorage = true;

          resolve(Saved.data);
        });
    });
  }

  /**
   * colour should be a hex value
   */
  static add (colour) {
    if (!Saved._fetchedFromStorage) {
      Saved.get()
        .then(() => {
          Saved._add(colour);
        });
    } else {
      Saved._add(colour);
    }
  }

  static _add (colour) {
    Saved.data.push(colour);

    Chrome.setSetting('saved', Saved.data);
  }
}
{'fraction_non_alphanumeric': 0.1437908496732026, 'fraction_numerical': 0.0, 'mean_word_length': 1.9647887323943662, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '3075312', 'n_tokens_mistral': 551, 'n_tokens_neox': 524, 'n_words': 108}