<commit_before>import React from 'react';
import { connect } from 'react-redux';
import moment from 'moment';
import { Feed, Icon } from 'semantic-ui-react';
import { sendMessage } from '../actions/actions';
import MessageInput from './MessageInput.jsx';
// import Notification from './components/Notification'

class MessageFeed extends React.Component {

  showNewMsgNotification = (messages) => {
    if(messages.list.length > 0) {
      const latestMsgID = messages.list[messages.list.length - 1];
      const name = messages.entities[latestMsgID].username;
      const options = {
        body: messages.entities[latestMsgID].text
      }
      const notif = new Notification(name, options);
      setTimeout(notif.close.bind(notif), 4000);
    }
  }

  componentWillUpdate(nextProps) {
    this.showNewMsgNotification(nextProps.messages);
  }

  render () {
    const { users, messages } = this.props;
    console.log('this is messages: ',messages);
    // console.log('here are the keys from this.props.messages: ',Object.keys(this.props.messages));
    const messageList = messages.list.map(id => messages.entities[id]).map((m, i) => {
      //can I bind this here somewhere?
      console.log('this is m.id inside the render function: ', m.id);
      const date = m.timeStamp;
      const user = m.username;
      const text = m.text;
      return (
        <Feed.Event key={`${i}:${m.id}`}>
          <Feed.Content>
            <Feed.Summary date={date} user={user}/>
            <Feed.Extra text content={text} />
            <Feed.Meta>
              <Feed.Like>
                <Icon name='like' onClick={this.addLikes}/>something that listens for clicks here and counts up likes</Feed.Like>
            </Feed.Meta>
          </Feed.Content>
        </Feed.Event>
    )}
    )
    // console.log('this is messageList: ', messageList);
    return (
      <div>
        <Feed size='large'>
          {messageList}
        </Feed>
        <MessageInput/>
      </div>
    )
  }
}

function select({ users, messages }) {
  return { users, messages };
}

export default connect(select)(MessageFeed)

// <div>
//   <input
//     type="text"
//     id="input-message"
//     placeholder='enter a message'
//     onKeyUp={this.handleSend}
//   /><commit_msg>feat(feed): add like and timestamp<commit_after>import React from 'react';
import { connect } from 'react-redux';
import moment from 'moment';
import { Feed, Icon } from 'semantic-ui-react';
import { sendMessage } from '../actions/actions';
import MessageInput from './MessageInput.jsx';
// import Notification from './components/Notification'

class MessageFeed extends React.Component {

  showNewMsgNotification = (messages) => {
    if(messages.list.length > 0) {
      const latestMsgID = messages.list[messages.list.length - 1];
      const name = messages.entities[latestMsgID].username;
      const options = {
        body: messages.entities[latestMsgID].text
      }
      const notif = new Notification(name, options);
      setTimeout(notif.close.bind(notif), 4000);
    }
  }

  componentWillUpdate(nextProps) {
    this.showNewMsgNotification(nextProps.messages);
  }

  render () {
    const { users, messages } = this.props;
    console.log('this is messages: ',messages);
    // console.log('here are the keys from this.props.messages: ',Object.keys(this.props.messages));
    const messageList = messages.list.map(id => messages.entities[id]).map((m, i) => {
      const date = m.timeStamp;
      const user = m.username;
      const text = m.text;
      return (
        <Feed.Event key={`${i}:${m.id}`}>
          <Feed.Content>
            <Feed.Summary date={date} user={user}/>
            <Feed.Extra text content={text} />
            <Feed.Meta>
              <Feed.Like>
                <Icon name='like' onClick={this.addLikes}/>something that listens for clicks here and counts up likes</Feed.Like>
            </Feed.Meta>
          </Feed.Content>
        </Feed.Event>
    )}
    )
    // console.log('this is messageList: ', messageList);
    return (
      <div>
        <Feed size='large'>
          {messageList}
        </Feed>
        <MessageInput/>
      </div>
    )
  }
}

function select({ users, messages }) {
  return { users, messages };
}

export default connect(select)(MessageFeed)
{'fraction_non_alphanumeric': 0.14415463437354448, 'fraction_numerical': 0.0027945971122496508, 'mean_word_length': 2.576186511240633, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 45, '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': '7233318', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1254, 'n_words': 298}