<commit_before>import React from 'react'
import $ from 'jquery'
import Notify from '../notification'
import Loading from '../loading'

import List from '@react-mdc/list'
import FileListItem from './item/file'
import Tree from '../tree'

export default class FileList extends React.Component {
  constructor (props) {
    super(props)

    this.initState(props)
  }

  initState (props) {
    this.state = {
      files: [],
      loading: false,
      location: window.location.hash.substring(1),
      updateInterval: null
    }
  }

  componentWillReceiveProps (props) {
    this.initState(props)
  }

  componentWillMount () {
    $(window).on('hashchange', () => this.handleHashCHange())
    this.update()
    this.setState({
      updateInterval: setInterval(() => this.update(), 30000)
    })
  }

  componentWillUnmount () {
    $(window).off('hashchange', () => this.handleHashCHange())
    clearInterval(this.state.updateInterval)
    this.setState({
      updateInterval: null
    })
  }

  handleHashCHange () {
    this.changeDir(window.location.hash.substring(1))
  }
  update () {
    this.setState({
      loading: true
    })

    $.ajax({
      method: 'GET',
      url: `/folder/${this.state.location}`,
      success: (response) => {
        this.setState({
          files: response.childs,
          loading: false
        })
      }
    }).fail((response) => {
      let text = response.responseJSON.err

      this.setState({
        loading: false
      })

      Notify({
        type: 'error',
        title: 'Failed to fetch files',
        content: (
          <p>{text}</p>
        )
      })
    })
  }

  changeDir (dir) {
    this.setState({
      location: dir
    })
    this.update()
  }

  render () {
    const files = this.state.files.map((file, key) => <FileListItem key={key} color={key % 2} file={file} onRemove={() => this.update()}/>)
    return (
      <List className="list" id="file">
        <Loading hidden={!this.state.loading}/>
        <Tree path={this.state.location} />
        {files}
      </List>
    )
  }
}<commit_msg>enable loading only on changedir<commit_after>import React from 'react'
import $ from 'jquery'
import Notify from '../notification'
import Loading from '../loading'

import List from '@react-mdc/list'
import FileListItem from './item/file'
import Tree from '../tree'

export default class FileList extends React.Component {
  constructor (props) {
    super(props)

    this.initState(props)
  }

  initState (props) {
    this.state = {
      files: [],
      loading: false,
      location: window.location.hash.substring(1),
      updateInterval: null
    }
  }

  componentWillReceiveProps (props) {
    this.initState(props)
  }

  componentWillMount () {
    $(window).on('hashchange', () => this.handleHashCHange())
    this.update()
    this.setState({
      updateInterval: setInterval(() => this.update(), 30000)
    })
  }

  componentWillUnmount () {
    $(window).off('hashchange', () => this.handleHashCHange())
    clearInterval(this.state.updateInterval)
    this.setState({
      updateInterval: null
    })
  }

  handleHashCHange () {
    this.changeDir(window.location.hash.substring(1))
  }
  update () {
    $.ajax({
      method: 'GET',
      url: `/folder/${this.state.location}`,
      success: (response) => {
        this.setState({
          files: response.childs,
          loading: false
        })
      }
    }).fail((response) => {
      let text = response.responseJSON.err

      this.setState({
        loading: false
      })

      Notify({
        type: 'error',
        title: 'Failed to fetch files',
        content: (
          <p>{text}</p>
        )
      })
    })
  }

  changeDir (dir) {
    this.setState({
      location: dir,
      loading: true
    })
    this.update()
  }

  render () {
    const files = this.state.files.map((file, key) => <FileListItem key={key} color={key % 2} file={file} onRemove={() => this.update()}/>)
    return (
      <List className="list" id="file">
        <Loading hidden={!this.state.loading}/>
        <Tree path={this.state.location} />
        {files}
      </List>
    )
  }
}
{'fraction_non_alphanumeric': 0.15588803088803088, 'fraction_numerical': 0.003861003861003861, 'mean_word_length': 2.3562753036437245, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 31, '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': '7467799', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1269, 'n_words': 261}