<commit_before>'use strict';

var React = require('react/addons');

var ArtworkImage = require('./ArtworkImage.js');
var Icon = require('./Icon.js');

var CollectionStore = require('../stores/CollectionStore.js');
var CollectionActions = require('../actions/CollectionActions.js');

var Covers = React.createClass({
  getInitialState: function() {
    return {
      list: [],
    };
  },

  componentDidMount: function() {
    CollectionStore.addChangeListener(this._onChange);
    CollectionActions.fetch(["Root"]);
  },

  componentWillUnmount: function() {
    CollectionStore.removeChangeListener(this._onChange);
  },

  render: function() {
    var covers = this.state.list.map(function(item) {
      return <Cover path={["Root"].concat(item.Key)} key={item.Key} item={item} />;
    });

    return (
      <div className="covers">
        {covers}
      </div>
    );
  },

  _onChange: function(path) {
    if (path === CollectionStore.pathToKey(["Root"])) {
      this.setState({
        list: CollectionStore.getCollection(["Root"]).Groups.slice(0, 30),
      });
    }
  },
});

var Cover = React.createClass({
  componentDidMount: function() {
    CollectionStore.addChangeListener(this._onChange);
    CollectionActions.fetch(this.props.path);
  },

  componentWillUnmount: function() {
    CollectionStore.removeChangeListener(this._onChange);
  },

  getInitialState: function() {
    return {
      item: this.props.item,
    };
  },

  render: function() {
    return (
      <div className="cover">
        <ArtworkImage path={"/artwork/"+this.state.item.TrackID} />
          <span className="controls">
            <Icon icon="play" title="Play Now" onClick={this._onPlayNow} />
            <Icon icon="list" title="Queue" onClick={this._onQueue} />
          </span>
      </div>
    );
  },

  _onChange: function(keyPath) {
    if (keyPath == CollectionStore.pathToKey(this.props.path)) {
      var item = CollectionStore.getCollection(this.props.path);
      this.setState({
        item: item,
      });
    }
  },

  _onPlayNow: function(e) {
    e.stopPropagation();
    CollectionActions.playNow(this.props.path);
  },

  _onQueue: function(e) {
    e.stopPropagation();
    CollectionActions.appendToPlaylist(this.props.path);
  },
});

module.exports = Covers;<commit_msg>[es6] Rewritten Covers components<commit_after>'use strict';

import React from 'react/addons';

import ArtworkImage from './ArtworkImage.js';
import Icon from './Icon.js';

import CollectionStore from '../stores/CollectionStore.js';
import CollectionActions from '../actions/CollectionActions.js';


export default class Covers extends React.Component {
  constructor(props) {
    super(props);

    this.state = {list: []};
    this._onChange = this._onChange.bind(this);
  }

  componentDidMount() {
    CollectionStore.addChangeListener(this._onChange);
    CollectionActions.fetch(["Root"]);
  }

  componentWillUnmount() {
    CollectionStore.removeChangeListener(this._onChange);
  }

  render() {
    var covers = this.state.list.map(function(item) {
      return <Cover path={["Root"].concat(item.Key)} key={item.Key} item={item} />;
    });

    return (
      <div className="covers">
        {covers}
      </div>
    );
  }

  _onChange(path) {
    if (path === CollectionStore.pathToKey(["Root"])) {
      this.setState({
        list: CollectionStore.getCollection(["Root"]).Groups.slice(0, 30),
      });
    }
  }
}


class Cover extends React.Component {
  constructor(props) {
    super(props);

    this.state = {item: this.props.item};
    this._onChange = this._onChange.bind(this);
    this._onPlayNow = this._onPlayNow.bind(this);
    this._onQueue = this._onQueue.bind(this);
  }

  componentDidMount() {
    CollectionStore.addChangeListener(this._onChange);
    CollectionActions.fetch(this.props.path);
  }

  componentWillUnmount() {
    CollectionStore.removeChangeListener(this._onChange);
  }

  render() {
    return (
      <div className="cover">
        <ArtworkImage path={"/artwork/"+this.state.item.TrackID} />
        <span className="controls">
          <Icon icon="play" title="Play Now" onClick={this._onPlayNow} />
          <Icon icon="list" title="Queue" onClick={this._onQueue} />
        </span>
      </div>
    );
  }

  _onChange(keyPath) {
    if (keyPath == CollectionStore.pathToKey(this.props.path)) {
      this.setState({item: CollectionStore.getCollection(this.props.path)});
    }
  }

  _onPlayNow(e) {
    e.stopPropagation();
    CollectionActions.playNow(this.props.path);
  }

  _onQueue(e) {
    e.stopPropagation();
    CollectionActions.appendToPlaylist(this.props.path);
  }
}
{'fraction_non_alphanumeric': 0.15813253012048192, 'fraction_numerical': 0.0015060240963855422, 'mean_word_length': 3.245662100456621, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, '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': '6073893', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1446, 'n_words': 225}