<commit_before>/* @flow */
/** @jsx etch.dom */

import etch from 'etch'
import DOMListener from 'dom-listener'
import {CompositeDisposable} from 'atom'

import type StatusBarViewModel from './status-bar-view-model'

type ClickFunction = (component: StatusBarComponent, event: Event) => void

export default class StatusBarComponent {
  element: HTMLElement;
  viewModel: StatusBarViewModel;
  subscriptions: CompositeDisposable;
  listener: DOMListener;

  constructor (viewModel: StatusBarViewModel, onClick: ClickFunction) {
    this.viewModel = viewModel
    this.subscriptions = new CompositeDisposable()

    this.subscriptions.add(viewModel.onDidChange(() => etch.update(this)))

    etch.initialize(this)

    this.subscriptions.add(atom.tooltips.add(this.element, {title: 'View changed files'}))

    this.listener = new DOMListener(this.element)
    this.subscriptions.add(this.listener.add(this.element, 'click', e => onClick(this, e)))
  }

  destroy (): Promise<void> {
    this.subscriptions.dispose()
    this.listener.destroy()

    return etch.destroy(this)
  }

  render () {
    return (
      <a className='git-status-bar inline-block icon icon-diff'>
        {this.viewModel.getChangedFileCount()} files
      </a>
    )<commit_msg>Pluralize the file count.<commit_after>/* @flow */
/** @jsx etch.dom */

import etch from 'etch'
import DOMListener from 'dom-listener'
import {CompositeDisposable} from 'atom'

import type StatusBarViewModel from './status-bar-view-model'

type ClickFunction = (component: StatusBarComponent, event: Event) => void

export default class StatusBarComponent {
  element: HTMLElement;
  viewModel: StatusBarViewModel;
  subscriptions: CompositeDisposable;
  listener: DOMListener;

  constructor (viewModel: StatusBarViewModel, onClick: ClickFunction) {
    this.viewModel = viewModel
    this.subscriptions = new CompositeDisposable()

    this.subscriptions.add(viewModel.onDidChange(() => etch.update(this)))

    etch.initialize(this)

    this.subscriptions.add(atom.tooltips.add(this.element, {title: 'View changed files'}))

    this.listener = new DOMListener(this.element)
    this.subscriptions.add(this.listener.add(this.element, 'click', e => onClick(this, e)))
  }

  destroy (): Promise<void> {
    this.subscriptions.dispose()
    this.listener.destroy()

    return etch.destroy(this)
  }

  render () {
    const fileCount = this.viewModel.getChangedFileCount()
    const fileLabel = fileCount === 1 ? '1 file' : `${fileCount} files`
    return (
      <a className='git-status-bar inline-block icon icon-diff'>{fileLabel}</a>
    )
{'fraction_non_alphanumeric': 0.12653846153846154, 'fraction_numerical': 0.0007692307692307692, 'mean_word_length': 4.265182186234818, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '2983532', 'n_tokens_mistral': 804, 'n_tokens_neox': 765, 'n_words': 175}