<commit_before>import React from 'react';
import _ from 'lodash';
import { connect } from 'react-redux';
import Icon from '../react/IconComponent';
import MessagePadDialogueList from './MessagePadDialogueListContainer';
import MessagePadDialogueContent from './MessagePadDialogueContentContainer';
import MessagePadInput from './MessagePadInputContainer';
import 'jquery.easing';

import * as util from '../../misc/Util';

const mapDispatchToProps = (dispatch) => ({
  loadDialogues() {
    dispatch({
      type: 'DIALOGUES_LOAD_DIALOGUES',
      payload: util.get(''),
    });
  },
  handleNewDialogue() {
    // TODO: pop up a dialog and pass udoc to store
    const uid = parseInt(prompt('UID'), 10);
    if (isNaN(uid)) {
      return;
    }
    dispatch({
      type: 'DIALOGUES_CREATE',
      payload: {
        id: _.uniqueId('PLACEHOLDER_'),
        uid,
      },
    });
  },
});

@connect(null, mapDispatchToProps)
export default class MessagePadContainer extends React.PureComponent {
  handleSwitch() {
    const BOUND_TOP = 60;
    const BOUND_BOTTOM = 20;
    const node = this.refs.container;
    if (node.offsetHeight + BOUND_TOP + BOUND_BOTTOM < window.innerHeight) {
      const rect = node.getBoundingClientRect();
      let targetScrollTop = null;
      if (rect.top < BOUND_TOP) {
        targetScrollTop = node.offsetTop - BOUND_TOP;
      } else if (rect.top + node.offsetHeight > window.innerHeight) {
        targetScrollTop = node.offsetTop + node.offsetHeight + BOUND_BOTTOM - window.innerHeight;
      }
      if (targetScrollTop !== null) {
        $('html, body').stop().animate({ scrollTop: targetScrollTop }, 200, 'easeOutCubic');
      }
    }
  }
  render() {
    return (
      <div className="messagepad clearfix" ref="container">
        <div className="messagepad__sidebar">
          <div className="section__header">
            <h1 className="section__title">Messages</h1>
            <div className="section__tools">
              <button
                onClick={() => this.props.handleNewDialogue()}
                className="tool-button"
              >
                <Icon name="add" /> New
              </button>
            </div>
          </div>
          <MessagePadDialogueList onSwitch={() => this.handleSwitch()} />
        </div>
        <MessagePadDialogueContent />
        <MessagePadInput />
      </div>
    );
  }
  componentDidMount() {
    this.props.loadDialogues();
  }
}
<commit_msg>forbid sending message to self in UI<commit_after>import React from 'react';
import _ from 'lodash';
import { connect } from 'react-redux';
import Icon from '../react/IconComponent';
import MessagePadDialogueList from './MessagePadDialogueListContainer';
import MessagePadDialogueContent from './MessagePadDialogueContentContainer';
import MessagePadInput from './MessagePadInputContainer';
import 'jquery.easing';

import * as util from '../../misc/Util';

const mapDispatchToProps = (dispatch) => ({
  loadDialogues() {
    dispatch({
      type: 'DIALOGUES_LOAD_DIALOGUES',
      payload: util.get(''),
    });
  },
  handleNewDialogue() {
    // TODO: pop up a dialog and pass udoc to store
    const uid = parseInt(prompt('UID'), 10);
    if (isNaN(uid)) {
      return;
    }
    if (uid === UserContext.uid) {
      return;
    }
    dispatch({
      type: 'DIALOGUES_CREATE',
      payload: {
        id: _.uniqueId('PLACEHOLDER_'),
        uid,
      },
    });
  },
});

@connect(null, mapDispatchToProps)
export default class MessagePadContainer extends React.PureComponent {
  handleSwitch() {
    const BOUND_TOP = 60;
    const BOUND_BOTTOM = 20;
    const node = this.refs.container;
    if (node.offsetHeight + BOUND_TOP + BOUND_BOTTOM < window.innerHeight) {
      const rect = node.getBoundingClientRect();
      let targetScrollTop = null;
      if (rect.top < BOUND_TOP) {
        targetScrollTop = node.offsetTop - BOUND_TOP;
      } else if (rect.top + node.offsetHeight > window.innerHeight) {
        targetScrollTop = node.offsetTop + node.offsetHeight + BOUND_BOTTOM - window.innerHeight;
      }
      if (targetScrollTop !== null) {
        $('html, body').stop().animate({ scrollTop: targetScrollTop }, 200, 'easeOutCubic');
      }
    }
  }
  render() {
    return (
      <div className="messagepad clearfix" ref="container">
        <div className="messagepad__sidebar">
          <div className="section__header">
            <h1 className="section__title">Messages</h1>
            <div className="section__tools">
              <button
                onClick={() => this.props.handleNewDialogue()}
                className="tool-button"
              >
                <Icon name="add" /> New
              </button>
            </div>
          </div>
          <MessagePadDialogueList onSwitch={() => this.handleSwitch()} />
        </div>
        <MessagePadDialogueContent />
        <MessagePadInput />
      </div>
    );
  }
  componentDidMount() {
    this.props.loadDialogues();
  }
}

{'fraction_non_alphanumeric': 0.1305655836341757, 'fraction_numerical': 0.004412354592860008, 'mean_word_length': 2.5851905104241553, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 43, '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': '8001', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1462, 'n_words': 320}