<commit_before>import React from 'react';
import { connect } from 'react-redux';

import config from '../config'
import actions from '../actions';

class Messenger extends React.Component {

  sendMessage() {
    const message = this.messageInput.value;
    this.props.sendMessage(this.props.chatId, message);
    this.messageInput.value = '';
    this.props.onSizeChanged(50);
  }

  onKeyUp(event) {
    event.persist();

    // Send message on 'return' key press
    if ( event.keyCode === 13 && !event.shiftKey ) {
      this.sendMessage();
    }

    // Update height of input element
    setTimeout(() => {
      this.props.onSizeChanged(50);
      let height = event.target.scrollHeight;
      this.props.onSizeChanged(height);
    }, 0);
  }

  render() {
    let messengerAttachmentClass = `c-messenger__attachment ${ this.props.showAttachment ? 'state-active' : '' }`;

    let inputHeight = { height: `${ this.props.messengerHeight }px` };

    return (
      <article className="c-messenger" style={ inputHeight }>
        <button className={ messengerAttachmentClass } onClick={ this.props.toggleAttachment }>
          <i className="icon-add-circle-outline"></i>
        </button>

        <textarea ref={ input => this.messageInput = input }
          style={ inputHeight }
          placeholder="Share knowledge"
          onKeyUp={ this.onKeyUp.bind(this) }
        ></textarea>

        <button className="c-messenger__submit" onClick={ () => this.sendMessage() }><commit_msg>Bind listener on key down to prevent new lines in text area when sending a message.<commit_after>import React from 'react';
import { connect } from 'react-redux';

import config from '../config'
import actions from '../actions';

class Messenger extends React.Component {

  sendMessage() {
    const message = this.messageInput.value;
    this.props.sendMessage(this.props.chatId, message);
    this.messageInput.value = '';
    this.props.onSizeChanged(50);
  }

  onKeyDown(event) {
    event.persist();

    // Send message on 'return' key press
    if ( event.keyCode === 13 && !event.shiftKey ) {
      event.preventDefault();
      this.sendMessage();
    } else {
      setTimeout(() => {
        this.props.onSizeChanged(50);
        let height = event.target.scrollHeight;
        this.props.onSizeChanged(height);
      }, 0);
    }
  }

  render() {
    let messengerAttachmentClass = `c-messenger__attachment ${ this.props.showAttachment ? 'state-active' : '' }`;

    let inputHeight = { height: `${ this.props.messengerHeight }px` };

    return (
      <article className="c-messenger" style={ inputHeight }>
        <button className={ messengerAttachmentClass } onClick={ this.props.toggleAttachment }>
          <i className="icon-add-circle-outline"></i>
        </button>

        <textarea ref={ input => this.messageInput = input }
          style={ inputHeight }
          placeholder="Share knowledge"
          onKeyDown={ this.onKeyDown.bind(this) }
        ></textarea>

        <button className="c-messenger__submit" onClick={ () => this.sendMessage() }>
{'fraction_non_alphanumeric': 0.14002599090318388, 'fraction_numerical': 0.004548408057179987, 'mean_word_length': 2.942381562099872, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, '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': '1447151', 'n_tokens_mistral': 905, 'n_tokens_neox': 870, 'n_words': 198}