<commit_before>import loadTemplate from '../../../utils/loadTemplate';
import baseVw from '../../baseVw';
import { getExchangeRate } from '../../../utils/currency';

export default class extends baseVw {
  constructor(options = {}) {
    super({
      className: 'aboutBTCTicker pureFlex',
      ...options,
    });
  }

  getCurrentPrice() {
    return getExchangeRate('USD');
  }

  updatePrice() {
    const latestPrice = this.getCurrentPrice();
    if (latestPrice !== this.currentBTCPrice) {
      this.currentBTCPrice = latestPrice;
      this.render();
    }
  }

  render() {
    if (this.currentBTCPrice == null) {
      this.currentBTCPrice = this.getCurrentPrice(); 
    }

    loadTemplate('modals/about/btcticker.html', (t) => {
      this.$el.html(t({
        currentBTCPrice: this.currentBTCPrice.toFixed(2),
      }));
    });

    console.info('render');
    return this;
  }
}
<commit_msg>BTC Widget checks for price updates<commit_after>import loadTemplate from '../../../utils/loadTemplate';
import baseVw from '../../baseVw';
import { getExchangeRate } from '../../../utils/currency';


const RATE_EXPIRY_S = '300';

export default class extends baseVw {
  constructor(options = {}) {
    super({
      className: 'aboutBTCTicker pureFlex',
      ...options,
    });
  }

  getCurrentPrice() {
    return getExchangeRate('USD');
  }

  updatePrice() {
    const latestPrice = this.getCurrentPrice();
    if (latestPrice !== this.currentBTCPrice) {
      this.currentBTCPrice = latestPrice;
      this.render();
    }
  }

  remove() {
    clearInterval(this.refreshCode);
    console.info("Refresh checks stopped");
    super.remove();
  }

  render() {
    if (this.refreshCode == null) {
      this.refreshCode = setInterval(() => this.updatePrice(), RATE_EXPIRY_S*1000);
    }

    if (this.currentBTCPrice == null) {
      this.currentBTCPrice = this.getCurrentPrice(); 
    }

    loadTemplate('modals/about/btcticker.html', (t) => {
      this.$el.html(t({
        currentBTCPrice: this.currentBTCPrice.toFixed(2),
      }));
    });

    return this;
  }
}

{'fraction_non_alphanumeric': 0.16163069544364508, 'fraction_numerical': 0.004316546762589928, 'mean_word_length': 2.792727272727273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '3726899', 'n_tokens_mistral': 670, 'n_tokens_neox': 654, 'n_words': 120}