<commit_before>/*
* == BSD2 LICENSE ==
* Copyright (c) 2014, Tidepool Project
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the associated License, which is identical to the BSD 2-Clause
* License as published by the Open Source Initiative at opensource.org.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the License for more details.
*
* You should have received a copy of the License along with this program; if
* not, you can obtain one from Tidepool Project at tidepool.org.
* == BSD2 LICENSE ==
*/

var _ = require('lodash');
var React = require('react');
var bows = require('../bows');
var repeat = require('../core/repeat');

var DETECT_DELAY = 120000; // Scan every X milliseconds
var DETECT_TIMEOUT = null; // Scan forever

var Scan = React.createClass({
  propTypes: {
    onDetectDevices: React.PropTypes.func.isRequired
  },

  log: bows('Scan'),

  getInitialState: function() {
    return {
      scanning: true,
      error: null
    };
  },

  stopScanning: _.noop,

  componentDidMount: function() {
    this.log('Start scanning for devices...');
    setTimeout(this.startScanning, 1000);
  },

  componentWillUnmount: function() {
    this.log('Stop scanning for devices');
    //this.stopScanning();
  },

  render: function() {
    return (
      <div className="Scan">
        {this.renderError()}
        {this.renderScan()}
      </div>
    );
  },

  renderError: function() {
    if (!this.state.error) {
      return null;
    }

    return (
      <div className="Scan-status Scan-status--error">
        {'An error occured while scanning for devices.'}
      </div>
    );
  },

  renderScan: function() {
    if (this.state.scanning) {
      return null;
    }

    return (
      <div className="Scan-status">
        <button className="btn btn-secondary" onClick={this.startScanning}>
          {'Scan for devices'}
        </button>
      </div>
    );
  },

  startScanning: function() {
    this.setState({
      scanning: true,
      error: null
    });

    this.stopScanning = repeat(
      this.props.onDetectDevices, DETECT_DELAY, DETECT_TIMEOUT, this.handleScanEnd
    );
  },

  handleScanEnd: function(err) {
    this.setState({
      scanning: false,
      error: err
    });
  }
});

module.exports = Scan;
<commit_msg>remove call that causes react error<commit_after>/*
* == BSD2 LICENSE ==
* Copyright (c) 2014, Tidepool Project
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the associated License, which is identical to the BSD 2-Clause
* License as published by the Open Source Initiative at opensource.org.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the License for more details.
*
* You should have received a copy of the License along with this program; if
* not, you can obtain one from Tidepool Project at tidepool.org.
* == BSD2 LICENSE ==
*/

var _ = require('lodash');
var React = require('react');
var bows = require('../bows');
var repeat = require('../core/repeat');

var DETECT_DELAY = 120000; // Scan every X milliseconds
var DETECT_TIMEOUT = null; // Scan forever

var Scan = React.createClass({
  propTypes: {
    onDetectDevices: React.PropTypes.func.isRequired
  },

  log: bows('Scan'),

  getInitialState: function() {
    return {
      scanning: true,
      error: null
    };
  },

  stopScanning: _.noop,

  componentDidMount: function() {
    this.log('Start scanning for devices...');
    setTimeout(this.startScanning, 1000);
  },

  render: function() {
    return (
      <div className="Scan">
        {this.renderError()}
        {this.renderScan()}
      </div>
    );
  },

  renderError: function() {
    if (!this.state.error) {
      return null;
    }

    return (
      <div className="Scan-status Scan-status--error">
        {'An error occured while scanning for devices.'}
      </div>
    );
  },

  renderScan: function() {
    if (this.state.scanning) {
      return null;
    }
    return (
      <div className="Scan-status">
        <button className="btn btn-secondary" onClick={this.startScanning}>
          {'Scan for devices'}
        </button>
      </div>
    );
  },

  startScanning: function() {
    this.setState({
      scanning: true,
      error: null
    });

    this.stopScanning = repeat(
      this.props.onDetectDevices, DETECT_DELAY, DETECT_TIMEOUT, this.handleScanEnd
    );
  },

  handleScanEnd: function(err) {
    this.setState({
      scanning: false,
      error: err
    });
  }
});

module.exports = Scan;

{'fraction_non_alphanumeric': 0.12261806130903065, 'fraction_numerical': 0.007042253521126761, 'mean_word_length': 2.835583796664019, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5250892', 'n_tokens_mistral': 1494, 'n_tokens_neox': 1420, 'n_words': 450}