<commit_before>var React = require('react')
import md5 from 'md5'

import UserStore from '../stores/UserStore'
import userAuth from '../userAuth'
import botlerImage from 'file!../../assets/images/botler.png'

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

    this.state = {
      user: UserStore.getUserById(props.userId)
    }
    UserStore.listen(this._usersUpdated.bind(this))
  }

  _usersUpdated(users) {
    this.setState({
      user: users[this.props.userId]
    })
  }

  render() {
    let className = 'avatar';

    let style = {}
    let title = null

    if (this.props.default) {
      style = {
        backgroundImage: `url(${botlerImage})`,
      }
      title = '<NAME>'
    } else if (this.state.user) {
      let avatarUrl =
        'http://www.gravatar.com/avatar/' +
        md5(this.state.user.username) +
        '?d=retro'
      style = {
        backgroundImage: `url(${avatarUrl})`,
      }
      title = this.state.user.username
    }

    return (
      <div
        title={title}
        className={className}
        style={style}
        {...this.props} >
      </div>
    )
  }
}
<commit_msg>update user Avatar better<commit_after>var React = require('react')
import md5 from 'md5'

import UserStore from '../stores/UserStore'
import userAuth from '../userAuth'
import botlerImage from 'file!../../assets/images/botler.png'

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

    this.state = {
      user: UserStore.getUserById(props.userId)
    }
    UserStore.listen(this._usersUpdated.bind(this))
  }

  _usersUpdated(users) {
    this.setState({
      user: users[this.props.userId]
    })
  }
  componentWillReceiveProps(nextProps) {
    this.setState({
      user:  UserStore.getUserById(nextProps.userId)
    })
  }

  render() {
    let className = 'avatar';

    let style = {}
    let title = null

    if (this.props.default) {
      style = {
        backgroundImage: `url(${botlerImage})`,
      }
      title = '<NAME>'
    } else if (this.state.user) {
      let avatarUrl =
        'http://www.gravatar.com/avatar/' +
        md5(this.state.user.username) +
        '?d=retro'
      style = {
        backgroundImage: `url(${avatarUrl})`,
      }
      title = this.state.user.username
    }

    return (
      <div
        title={title}
        className={className}
        style={style}
        {...this.props} >
      </div>
    )
  }
}

{'fraction_non_alphanumeric': 0.14406438631790744, 'fraction_numerical': 0.002414486921529175, 'mean_word_length': 2.241199478487614, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5598995', 'n_tokens_mistral': 812, 'n_tokens_neox': 802, 'n_words': 149}