<commit_before>import cx from 'classnames';
import React from 'react';
import { togglePlaylistManager } from '../../actions/OverlayActionCreators';
import PlaylistStore from '../../stores/PlaylistStore';
import UserStore from '../../stores/UserStore';
import NextMedia from './NextMedia';
import UserInfo from './UserInfo';

function getState() {
  return {
    playlist: PlaylistStore.getActivePlaylist(),
    nextMedia: PlaylistStore.getActiveMedia()[0],
    user: UserStore.getCurrentUser()
  };
}

export default class FooterBar extends React.Component {
  static propTypes = {
    className: React.PropTypes.string
  };

  constructor() {
    super();
    this.onChange = this.onChange.bind(this);
  }

  state = getState();

  componentDidMount() {
    PlaylistStore.on('change', this.onChange);
    UserStore.on('change', this.onChange);
  }

  componentWillUnmount() {
    PlaylistStore.removeListener('change', this.onChange);
    UserStore.removeListener('change', this.onChange);
  }

  onChange() {
    this.setState(getState());
  }

  render() {
    const { user, playlist, nextMedia } = this.state;

    let tree;
    if (user && !user.isGuest) {
      tree = [
        <UserInfo user={user} />,
        <NextMedia
          playlist={playlist}
          nextMedia={nextMedia}
          onClick={togglePlaylistManager}
        />
      ];
    } else {
      tree = <div className="FooterBar-guest">You have to log in if you want to play!</div>;
    }

    return (
      <div className={cx('FooterBar', this.props.className)}>
        {tree}
      </div>
    );
  }
}<commit_msg>footer: simplify footer bar rendering<commit_after>import cx from 'classnames';
import React from 'react';
import { togglePlaylistManager } from '../../actions/OverlayActionCreators';
import PlaylistStore from '../../stores/PlaylistStore';
import UserStore from '../../stores/UserStore';
import NextMedia from './NextMedia';
import UserInfo from './UserInfo';

function getState() {
  return {
    playlist: PlaylistStore.getActivePlaylist(),
    nextMedia: PlaylistStore.getActiveMedia()[0],
    user: UserStore.getCurrentUser()
  };
}

export default class FooterBar extends React.Component {
  static propTypes = {
    className: React.PropTypes.string
  };

  constructor() {
    super();
    this.onChange = this.onChange.bind(this);
  }

  state = getState();

  componentDidMount() {
    PlaylistStore.on('change', this.onChange);
    UserStore.on('change', this.onChange);
  }

  componentWillUnmount() {
    PlaylistStore.removeListener('change', this.onChange);
    UserStore.removeListener('change', this.onChange);
  }

  onChange() {
    this.setState(getState());
  }

  render() {
    const { user, playlist, nextMedia } = this.state;
    const className = cx('FooterBar', this.props.className);

    if (user && !user.isGuest) {
      return (
        <div className={className}>
          <UserInfo user={user} />
          <NextMedia
            playlist={playlist}
            nextMedia={nextMedia}
            onClick={togglePlaylistManager}
          />
        </div>
      );
    }
    return (
      <div className={className}>
        <div className="FooterBar-guest">You have to log in if you want to play!</div>
      </div>
    );
  }
}
{'fraction_non_alphanumeric': 0.14119091467157766, 'fraction_numerical': 0.0006138735420503376, 'mean_word_length': 3.008610086100861, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '913804', 'n_tokens_mistral': 973, 'n_tokens_neox': 968, 'n_words': 209}