<commit_before>import { LocalizationProps, Localized, withLocalization } from 'fluent-react';
import * as React from 'react';
import { connect } from 'react-redux';
import API from '../../../services/api';
import StateTree from '../../../stores/tree';
import { User } from '../../../stores/user';
import URLS from '../../../urls';
import { LocaleLink } from '../../locale-helpers';
import { CheckIcon, MicIcon, PlayOutlineIcon } from '../../ui/icons';
import { Button, LinkButton, TextButton } from '../../ui/ui';
import { SET_COUNT } from './contribution';

import './success.css';

const COUNT_UP_MS = 500; // should be kept in sync with .contribution-success .done transition duration
const DAILY_GOAL = Object.freeze({ speak: 600, listen: 1200 });

const GoalPercentage = ({
  current,
  final,
}: {
  current: number;
  final: number;
}) => (
  <span className="goal-percentage">
    <span className="final">{final}%</span>
    <span className="current">{current}%</span>
  </span>
);

interface PropsFromState {
  api: API;
  hasEnteredInfo: boolean;
}

interface Props extends LocalizationProps, PropsFromState {
  type: 'speak' | 'listen';
  onReset: () => any;
}

interface State {
  contributionCount: number;
  currentCount: number;
}

class Success extends React.Component<Props, State> {
  state: State = { contributionCount: null, currentCount: null };

  async componentDidMount() {
    const { api, type } = this.props;
    this.setState(
      {
        contributionCount:
          (await (type === 'speak'
            ? api.fetchDailyClipsCount()
            : api.fetchDailyVotesCount())) + SET_COUNT,
      },
      () => this.countUp(performance.now())
    );
  }

  private startedAt: number;
  private countUp = (time: number) => {<commit_msg>kill success animation when unmounting<commit_after>import { LocalizationProps, Localized, withLocalization } from 'fluent-react';
import * as React from 'react';
import { connect } from 'react-redux';
import API from '../../../services/api';
import StateTree from '../../../stores/tree';
import { User } from '../../../stores/user';
import URLS from '../../../urls';
import { LocaleLink } from '../../locale-helpers';
import { CheckIcon, MicIcon, PlayOutlineIcon } from '../../ui/icons';
import { Button, LinkButton, TextButton } from '../../ui/ui';
import { SET_COUNT } from './contribution';

import './success.css';

const COUNT_UP_MS = 500; // should be kept in sync with .contribution-success .done transition duration
const DAILY_GOAL = Object.freeze({ speak: 600, listen: 1200 });

const GoalPercentage = ({
  current,
  final,
}: {
  current: number;
  final: number;
}) => (
  <span className="goal-percentage">
    <span className="final">{final}%</span>
    <span className="current">{current}%</span>
  </span>
);

interface PropsFromState {
  api: API;
  hasEnteredInfo: boolean;
}

interface Props extends LocalizationProps, PropsFromState {
  type: 'speak' | 'listen';
  onReset: () => any;
}

interface State {
  contributionCount: number;
  currentCount: number;
}

class Success extends React.Component<Props, State> {
  state: State = { contributionCount: null, currentCount: null };

  killAnimation = false;

  async componentDidMount() {
    const { api, type } = this.props;
    this.setState(
      {
        contributionCount:
          (await (type === 'speak'
            ? api.fetchDailyClipsCount()
            : api.fetchDailyVotesCount())) + SET_COUNT,
      },
      () => this.countUp(performance.now())
    );
  }

  componentWillUnmount() {
    this.killAnimation = true;
  }

  private startedAt: number;
  private countUp = (time: number) => {
    if (this.killAnimation) return;
{'fraction_non_alphanumeric': 0.16150922909880563, 'fraction_numerical': 0.0054288816503800215, 'mean_word_length': 3.3506493506493507, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 25, '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': '2006792', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1118, 'n_words': 298}