<commit_before>import React, {PropTypes} from 'react';
import {connect} from 'react-redux';
import {updatePath} from 'redux-simple-router';
import {getFile} from '../../actions/files';
import nodeify from 'nodeify';

import ViewerText from '../components/viewers/Text'
import ViewerUrl from '../components/viewers/Url'
import ViewerVideo from '../components/viewers/Video'
import ViewerCode from '../components/viewers/Code'
import ViewerImage from '../components/viewers/Image'
import ViewerDefault from '../components/viewers/Default'

@connect(state => {
  return {
    file: state.files.data
}}, {
  updatePath
})
export default class File extends React.Component {
  static propTypes = {
    file: PropTypes.object.isRequired,
    updatePath: PropTypes.func.isRequired
  }

  constructor(props, context) {
    super(props, context);
  }

  render() {
    if(!this.props.file)
      return(<h1>Error</h1>);

    let viewer;
    switch(this.props.file.type) {
      case 'text':
        viewer = <ViewerText data={this.props.file} />;
        break;
      case 'url':
        viewer = <ViewerUrl data={this.props.file} />;
        break;
      case 'video':
        viewer = <ViewerVideo data={this.props.file} />;
        break;
      case 'code':
        viewer = <ViewerCode data={this.props.file} />;
        break;
      case 'image':
        viewer = <ViewerImage data={this.props.file} />;
        break;
      default:
        viewer = <ViewerDefault data={this.props.file} />;
        break;
    }

    return (
      <div className="file">
        {viewer}
      </div>
    );
  }<commit_msg>Solved an issue with uploaded text files<commit_after>import React, {PropTypes} from 'react';
import {connect} from 'react-redux';
import {updatePath} from 'redux-simple-router';
import {getFile} from '../../actions/files';
import nodeify from 'nodeify';

import ViewerText from '../components/viewers/Text'
import ViewerUrl from '../components/viewers/Url'
import ViewerVideo from '../components/viewers/Video'
import ViewerCode from '../components/viewers/Code'
import ViewerImage from '../components/viewers/Image'
import ViewerDefault from '../components/viewers/Default'

@connect(state => {
  return {
    file: state.files.data
}}, {
  updatePath
})
export default class File extends React.Component {
  static propTypes = {
    file: PropTypes.object.isRequired,
    updatePath: PropTypes.func.isRequired
  }

  constructor(props, context) {
    super(props, context);
  }

  render() {
    if(!this.props.file)
      return(<h1>Error</h1>);

    let viewer;
    switch(this.props.file.type) {
      case 'text':
        viewer = this.props.file.text ? <ViewerText data={this.props.file} /> : <ViewerDefault data={this.props.file} />;
        break;
      case 'url':
        viewer = <ViewerUrl data={this.props.file} />;
        break;
      case 'video':
        viewer = <ViewerVideo data={this.props.file} />;
        break;
      case 'code':
        viewer = <ViewerCode data={this.props.file} />;
        break;
      case 'image':
        viewer = <ViewerImage data={this.props.file} />;
        break;
      default:
        viewer = <ViewerDefault data={this.props.file} />;
        break;
    }

    return (
      <div className="file">
        {viewer}
      </div>
    );
  }
{'fraction_non_alphanumeric': 0.14623069936421434, 'fraction_numerical': 0.0012110202845897668, 'mean_word_length': 2.7333333333333334, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 26, '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': '5370025', 'n_tokens_mistral': 1031, 'n_tokens_neox': 1022, 'n_words': 233}