<commit_before>/** @jsx React.DOM */

(function(){
  var LoveStore = require('../stores/love_store')
  var LoveActionCreators = require('../actions/love_action_creators')
  var xhr = require('../xhr')
  var Lovers = require('./lovers.jsx')

  var Love = React.createClass({
    propTypes: {
      heartable_id: React.PropTypes.string.isRequired,
      heartable_type: React.PropTypes.string.isRequired
    },

    render: function() {
      if (!window.app.featureEnabled('much-love') && !this.props.public) {
        return <span/>
      }

      if (this.state.hearts_count == null) {
        return <span/>
      }

      var style = {
        fontSize: 18,
      }
      if (this.state.user_heart) {
        style['color'] = 'rgba(236,55,79,1)'
      }

      return <span>
        <a className="gray left mr1" href="javascript:;" onClick={this.handleClick}>
          <span className="fa fa-heart" style={style}></span>
        </a>
        <Lovers heartable_id={this.props.heartable_id} hearts_count={this.state.hearts_count} />
      </span>
    },

    getInitialState: function() {
      return this.getStateFromStore()
    },

    componentDidMount: function() {
      LoveStore.addListener('change', this._onChange)
    },

    componentWillUnmount: function() {
      LoveStore.removeListener('change', this._onChange)
    },

    handleClick: function() {
      if (this.state.user_heart) {
        LoveActionCreators.clickUnlove(this.props.heartable_type, this.props.heartable_id)
      } else {
        LoveActionCreators.clickLove(this.props.heartable_type, this.props.heartable_id)
      }
    },

    getStateFromStore: function() {
      return LoveStore.get(this.props.heartable_id)
    },

    _onChange: function() {
      this.replaceState(this.getStateFromStore())<commit_msg>Fix love component bug<commit_after>/** @jsx React.DOM */

(function(){
  var LoveStore = require('../stores/love_store')
  var LoveActionCreators = require('../actions/love_action_creators')
  var xhr = require('../xhr')
  var Lovers = require('./lovers.jsx')

  var Love = React.createClass({
    propTypes: {
      heartable_id: React.PropTypes.string.isRequired,
      heartable_type: React.PropTypes.string.isRequired
    },

    render: function() {
      if (!window.app.featureEnabled('much-love') && !this.props.public) {
        return <span/>
      }

      if (this.state.hearts_count == null) {
        return <span/>
      }

      var style = {
        fontSize: 18,
      }
      if (this.state.user_heart) {
        style['color'] = 'rgba(236,55,79,1)'
      }

      return <span>
        <a className="gray left mr1" href="javascript:;" onClick={this.handleClick}>
          <span className="fa fa-heart" style={style}></span>
        </a>
        <Lovers heartable_id={this.props.heartable_id} hearts_count={this.state.hearts_count} />
      </span>
    },

    getInitialState: function() {
      return this.getStateFromStore()
    },

    componentDidMount: function() {
      LoveStore.addListener('change', this._onChange)
    },

    componentWillUnmount: function() {
      LoveStore.removeListener('change', this._onChange)
    },

    handleClick: function() {
      if (this.state.user_heart) {
        LoveActionCreators.clickUnlove(this.props.heartable_type, this.props.heartable_id)
      } else {
        LoveActionCreators.clickLove(this.props.heartable_type, this.props.heartable_id)
      }
    },

    getStateFromStore: function() {
      return LoveStore.get(this.props.heartable_id)
    },

    _onChange: function() {
      this.replaceState(this.getStateFromStore() || {})
{'fraction_non_alphanumeric': 0.14384508990318118, 'fraction_numerical': 0.006085753803596127, 'mean_word_length': 2.7666666666666666, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '6604389', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1134, 'n_words': 180}