<commit_before>/*
 * Copyright (C) 2015 Actor LLC. <https://actor.im>
 */

import { escape } from 'lodash';
import React, { Component, PropTypes } from 'react';
import ReactMixin from 'react-mixin';
import { IntlMixin } from 'react-intl'
import addons from 'react/addons';
import classnames from 'classnames';
import { escapeWithEmoji } from '../../../utils/EmojiUtils';
import PeerUtils from '../../../utils/PeerUtils';
import { MessageContentTypes } from '../../../constants/ActorAppConstants';

import VisibilitySensor from 'react-visibility-sensor';

import DialogActionCreators from '../../../actions/DialogActionCreators';
import MessageActionCreators from '../../../actions/MessageActionCreators';
import ActivityActionCreators from '../../../actions/ActivityActionCreators';
import ComposeActionCreators from '../../../actions/ComposeActionCreators';
import DropdownActionCreators from '../../../actions/DropdownActionCreators';

import UserStore from '../../../stores/UserStore';
import DropdownStore from '../../../stores/DropdownStore';

import AvatarItem from '../../common/AvatarItem.react';
import State from './State.react';
import Reactions from './Reactions.react';

// Default message content components
import DefaultService from './Service.react';
import DefaultText from './Text.react';
import DefaultPhoto from './Photo.react.js';
import DefaultDocument from './Document.react';
import DefaultVoice from './Voice.react';
import DefaultContact from './Contact.react';
import DefaultLocation from './Location.react.js';
import DefaultModern from './Modern.react.js';
import DefaultSticker from './Sticker.react.js';

const {addons: { PureRenderMixin }} = addons;

class MessageItem extends Component {
  static propTypes = {
    peer: PropTypes.object.isRequired,
    message: PropTypes.object.isRequired,
    isShortMessage: PropTypes.bool,
    isSelected: PropTypes.bool,
    onVisibilityChange: PropTypes.func,
    onSelect: PropTypes.func
  };

  static contextTypes = {
    delegate: PropTypes.object,
    isExperimental: PropTypes.bool
  };

  constructor(props) {
    super(props);

    this.state = {
      isHighlighted: DropdownStore.isOpen(props.message.rid)
    };

    DropdownStore.addListener(this.onMessagesChange);
  }

  onMessagesChange = () => {
    const { message } = this.props;
    this.setState({isHighlighted: DropdownStore.isOpen(message.rid)});
  };

  onClick = () => {
    const { message, peer } = this.props;

    if (PeerUtils.equals(peer, message.sender.peer)) {
      ActivityActionCreators.show();
    } else {
      DialogActionCreators.selectDialogPeerUser(message.sender.peer.id);
    }
  };

  onVisibilityChange = (isVisible) => {
    const { message, onVisibilityChange } = this.props;
    onVisibilityChange(message, isVisible);
  };

  showActions = (event) => {
    const { message } = this.props;
    DropdownActionCreators.openMessageActions(event.target.getBoundingClientRect(), message);
  };

  toggleMessageSelection = () => {
    const { message, onSelect } = this.props;
    onSelect && onSelect(message.rid);
  };

  render() {
    const { message, isShortMessage, onVisibilityChange, peer, isSelected } = this.props;
    const { isHighlighted } = this.state;
    const { delegate, isExperimental } = this.context;

    let Service, Text, Modern, Photo, Document, Voice, Contact, Location, Sticker;
    if (delegate.components.dialog !== null && delegate.components.dialog.messages) {
      Service = delegate.components.dialog.messages.service || DefaultService;<commit_msg>fix(web): don't send reads for own messages #235<commit_after>/*
 * Copyright (C) 2015 Actor LLC. <https://actor.im>
 */

import { escape } from 'lodash';
import React, { Component, PropTypes } from 'react';
import ReactMixin from 'react-mixin';
import { IntlMixin } from 'react-intl'
import addons from 'react/addons';
import classnames from 'classnames';
import { escapeWithEmoji } from '../../../utils/EmojiUtils';
import PeerUtils from '../../../utils/PeerUtils';
import { MessageContentTypes } from '../../../constants/ActorAppConstants';

import VisibilitySensor from 'react-visibility-sensor';

import DialogActionCreators from '../../../actions/DialogActionCreators';
import MessageActionCreators from '../../../actions/MessageActionCreators';
import ActivityActionCreators from '../../../actions/ActivityActionCreators';
import ComposeActionCreators from '../../../actions/ComposeActionCreators';
import DropdownActionCreators from '../../../actions/DropdownActionCreators';

import UserStore from '../../../stores/UserStore';
import DropdownStore from '../../../stores/DropdownStore';

import AvatarItem from '../../common/AvatarItem.react';
import State from './State.react';
import Reactions from './Reactions.react';

// Default message content components
import DefaultService from './Service.react';
import DefaultText from './Text.react';
import DefaultPhoto from './Photo.react.js';
import DefaultDocument from './Document.react';
import DefaultVoice from './Voice.react';
import DefaultContact from './Contact.react';
import DefaultLocation from './Location.react.js';
import DefaultModern from './Modern.react.js';
import DefaultSticker from './Sticker.react.js';

const {addons: { PureRenderMixin }} = addons;

class MessageItem extends Component {
  static propTypes = {
    peer: PropTypes.object.isRequired,
    message: PropTypes.object.isRequired,
    isShortMessage: PropTypes.bool,
    isSelected: PropTypes.bool,
    onVisibilityChange: PropTypes.func,
    onSelect: PropTypes.func
  };

  static contextTypes = {
    delegate: PropTypes.object,
    isExperimental: PropTypes.bool
  };

  constructor(props) {
    super(props);

    this.state = {
      isHighlighted: DropdownStore.isOpen(props.message.rid)
    };

    DropdownStore.addListener(this.onMessagesChange);
  }

  onMessagesChange = () => {
    const { message } = this.props;
    this.setState({isHighlighted: DropdownStore.isOpen(message.rid)});
  };

  onClick = () => {
    const { message, peer } = this.props;

    if (PeerUtils.equals(peer, message.sender.peer)) {
      ActivityActionCreators.show();
    } else {
      DialogActionCreators.selectDialogPeerUser(message.sender.peer.id);
    }
  };

  onVisibilityChange = (isVisible) => {
    const { message, onVisibilityChange } = this.props;
    if (message.sender.peer.id !== UserStore.getMyId()) {
      onVisibilityChange(message, isVisible);
    }
  };

  showActions = (event) => {
    const { message } = this.props;
    DropdownActionCreators.openMessageActions(event.target.getBoundingClientRect(), message);
  };

  toggleMessageSelection = () => {
    const { message, onSelect } = this.props;
    onSelect && onSelect(message.rid);
  };

  render() {
    const { message, isShortMessage, onVisibilityChange, peer, isSelected } = this.props;
    const { isHighlighted } = this.state;
    const { delegate, isExperimental } = this.context;

    let Service, Text, Modern, Photo, Document, Voice, Contact, Location, Sticker;
    if (delegate.components.dialog !== null && delegate.components.dialog.messages) {
      Service = delegate.components.dialog.messages.service || DefaultService;
{'fraction_non_alphanumeric': 0.1425197944158911, 'fraction_numerical': 0.0015279899986109181, 'mean_word_length': 3.8979591836734695, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 2, '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': '2893462', 'n_tokens_mistral': 2021, 'n_tokens_neox': 2008, 'n_words': 477}