<commit_before>import React, {PropTypes} from 'react';
import {Map} from 'immutable';
import cx from 'classnames';
import './styles.scss';
import moment from 'moment';


export default class Message extends React.Component {

  static propTypes = {
    sender: PropTypes.instanceOf(Map).isRequired,
    text: PropTypes.string.isRequired,
    timestamp: PropTypes.timestamp.isRequired,
    currentUserId: PropTypes.string.isRequired,
  }


  constructor(props) {
    super(props);
    this.state = {
      date: null,
    };
  }


  componentDidMount = () => {
    setInterval(()=>{
      this.updateTime(this.props.timestamp);
    }, 5000);
  }


  updateTime = (timestamp) => {
    const date = moment.duration(moment().diff(moment(timestamp))).humanize();
    this.setState({
      date: date,
    });
  }


  renderAvatar = (sender) => {
    return (
      <div className='message__avatar'>
        <img
          className='message__img'
          src={sender.get('avatar')}
          width='50'
          height='50'
        />
      </div>
    );
  }


  render() {
    const {sender, text, currentUserId} = this.props;
    const isSelfMessage = sender.get('id') === currentUserId;
    return (
      <li className='message'><commit_msg>feat(components): fix proptypes, clear interval after unmount message<commit_after>import React, {PropTypes} from 'react';
import {Map} from 'immutable';
import cx from 'classnames';
import './styles.scss';
import moment from 'moment';


export default class Message extends React.Component {

  static propTypes = {
    sender: PropTypes.instanceOf(Map).isRequired,
    text: PropTypes.string.isRequired,
    timestamp: PropTypes.string.isRequired,
    currentUserId: PropTypes.string.isRequired,
  }


  constructor(props) {
    super(props);
    this.state = {
      date: null,
    };
  }


  componentDidMount = () => {
    this.updateTime();
    this.timer = setInterval(()=>{
      this.updateTime(this.props.timestamp);
    }, 5000);
  }


  componentWillUnmount = () => {
    clearInterval(this.timer);
  }


  updateTime = (timestamp) => {
    const date = moment.duration(moment().diff(moment(timestamp))).humanize();
    this.setState({
      date: date,
    });
  }


  renderAvatar = (sender) => {
    return (
      <div className='message__avatar'>
        <img
          className='message__img'
          src={sender.get('avatar')}
          width='50'
          height='50'
        />
      </div>
    );
  }


  render() {
    const {sender, text, currentUserId} = this.props;
    const isSelfMessage = sender.get('id') === currentUserId;
    return (
      <li className='message'>
{'fraction_non_alphanumeric': 0.1440453686200378, 'fraction_numerical': 0.0060491493383742915, 'mean_word_length': 2.829232995658466, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 20, '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': '6020071', 'n_tokens_mistral': 816, 'n_tokens_neox': 794, 'n_words': 162}