<commit_before>import React from 'react'
import _ from 'lodash'
import axios from 'axios'

import InjectedComponent from '~/components/Injected'
import EventBus from '~/util/EventBus'

export default class InjectedModuleView extends React.Component {

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

    this.state = {
      moduleComponent: null
    }
  }

  loadModule(modName, viewName) {
    const moduleName = modName || this.props.moduleName
    const subView = viewName || this.props.viewName || 'default'

    if (moduleName === this.state.moduleName && subView == this.state.viewName) {
      return
    }

    this.setState({ moduleComponent: null, moduleName: moduleName, viewName: viewName })

    if (!window.botpress || !window.botpress[moduleName]) {
      var script = document.createElement("script")
      script.type = "text/javascript"
      script.onload = () => {
        script.onload = null
        setImmediate(() => {
          this.setViewInState(moduleName, subView)
        })
      }
      script.src = `/js/modules/${moduleName}.js`
      document.getElementsByTagName("head")[0].appendChild(script)
    } else {
      this.setState({ moduleComponent: null })
      setImmediate(() => {
        this.setViewInState(moduleName, subView)
      })
    }
  }

  setViewInState(moduleName, viewName) {
    if (_.isNil(_.get(window, `botpress.${moduleName}.${viewName}`))) {
      console.log('IS NILL', moduleName, viewName, window.botpress)
      this.setState({
        error: new Error(`Subview "${viewName}" doesn't exist for module "${moduleName}"`),
        moduleComponent: null
      })
    } else {
      this.setState({
        moduleComponent: window.botpress[moduleName][viewName],
        error: null
      })
    }
  }<commit_msg>Removed leftover<commit_after>import React from 'react'
import _ from 'lodash'
import axios from 'axios'

import InjectedComponent from '~/components/Injected'
import EventBus from '~/util/EventBus'

export default class InjectedModuleView extends React.Component {

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

    this.state = {
      moduleComponent: null
    }
  }

  loadModule(modName, viewName) {
    const moduleName = modName || this.props.moduleName
    const subView = viewName || this.props.viewName || 'default'

    if (moduleName === this.state.moduleName && subView == this.state.viewName) {
      return
    }

    this.setState({ moduleComponent: null, moduleName: moduleName, viewName: viewName })

    if (!window.botpress || !window.botpress[moduleName]) {
      var script = document.createElement("script")
      script.type = "text/javascript"
      script.onload = () => {
        script.onload = null
        setImmediate(() => {
          this.setViewInState(moduleName, subView)
        })
      }
      script.src = `/js/modules/${moduleName}.js`
      document.getElementsByTagName("head")[0].appendChild(script)
    } else {
      this.setState({ moduleComponent: null })
      setImmediate(() => {
        this.setViewInState(moduleName, subView)
      })
    }
  }

  setViewInState(moduleName, viewName) {
    if (_.isNil(_.get(window, `botpress.${moduleName}.${viewName}`))) {
      this.setState({
        error: new Error(`Subview "${viewName}" doesn't exist for module "${moduleName}"`),
        moduleComponent: null
      })
    } else {
      this.setState({
        moduleComponent: window.botpress[moduleName][viewName],
        error: null
      })
    }
  }
{'fraction_non_alphanumeric': 0.13297111810122964, 'fraction_numerical': 0.0005719187875321705, 'mean_word_length': 2.9885974914481186, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6882301', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1035, 'n_words': 212}