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

import config from '../config';
import actions from '../actions';
import SwipeView from './scopes.swipe-view';
import Chat from './scopes.chat';
import Profile from './scopes.profile';
import ChatSettings from './scopes.chat-settings';
import Stats from './scopes.stats';

class Conversation extends React.Component {
  render() {
    let view;

    const chat = this.state && this.props.chatsState.chats[this.state.chatId];

    if (chat) {
      let group = chat.members.length > 2;
      let groupName = 'We are TMNT';
      let groupImage = 'http://placehold.it/500x200';
      let participants = [];

      if (group) {
        view = <ChatSettings
          groupName={ groupName }
          groupImage={ groupImage }
          participants={ participants }
        />
      } else if (this.state.contactId && this.props.contactsState.contacts[this.state.contactId]) {
        view = <Profile
          isRoot={ false }
          user={ this.props.contactsState.contacts[this.state.contactId] }
        />
      }
    }

    return (
      <main className="s-conversation">
        <SwipeView swipeViewId={ swipeViewId }>
          <Chat chat={ chat }/>
          { view }
          <Stats/>
        </SwipeView>
      </main>
    );
  }

  componentDidMount() {
    this.props.setChatHeader();

    if (this.props.params.chatId) { this.loadInitialData(); }
  }

  getContactId(chat) {
    return chat.members.filter((member) =>
      member.id != this.props.meState.id
    )[0].id;
  }

  async loadInitialData() {
    if (!this.props.chatsState.chats[this.props.params.chatId]) {
      // fetch the chat.<commit_msg>Added 'new' conversation else case to the chat settings view.<commit_after>import React from 'react';
import { connect } from 'react-redux';

import config from '../config';
import actions from '../actions';
import SwipeView from './scopes.swipe-view';
import Chat from './scopes.chat';
import Profile from './scopes.profile';
import ChatSettings from './scopes.chat-settings';
import Stats from './scopes.stats';

class Conversation extends React.Component {
  render() {
    let view;

    const chat = this.state && this.props.chatsState.chats[this.state.chatId];

    if (chat) {
      // Existing conversation
      let group = chat.members.length > 2;
      let groupName = 'We are TMNT';
      let groupImage = 'http://placehold.it/500x200';
      let participants = [];

      if (group) {
        view = <ChatSettings
          groupName={ groupName }
          groupImage={ groupImage }
          participants={ participants }
        />
      } else if (this.state.contactId && this.props.contactsState.contacts[this.state.contactId]) {
        view = <Profile
          isRoot={ false }
          user={ this.props.contactsState.contacts[this.state.contactId] }
        />
      }
    } else {
      // New conversation
      let groupName = 'Group Name';
      let groupImage = '';
      let participants = [];

      view = <ChatSettings
        groupName={ groupName }
        groupImage={ groupImage }
        participants={ participants }
      />
    }

    return (
      <main className="s-conversation">
        <SwipeView swipeViewId={ swipeViewId }>
          <Chat chat={ chat }/>
          { view }
          <Stats/>
        </SwipeView>
      </main>
    );
  }

  componentDidMount() {
    this.props.setChatHeader();

    if (this.props.params.chatId) { this.loadInitialData(); }
  }

  getContactId(chat) {
    return chat.members.filter((member) =>
      member.id != this.props.meState.id
    )[0].id;
  }

  async loadInitialData() {
    if (!this.props.chatsState.chats[this.props.params.chatId]) {
      // fetch the chat.
{'fraction_non_alphanumeric': 0.13712463460005314, 'fraction_numerical': 0.004251926654265214, 'mean_word_length': 2.3607142857142858, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 24, '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': '1541876', 'n_tokens_mistral': 1141, 'n_tokens_neox': 1110, 'n_words': 257}