<commit_before>/*
 * Logspace
 * Copyright (c) 2015 Indoqa Software Design und Beratung GmbH. All rights reserved.
 * This program and the accompanying materials are made available under the terms of
 * the Eclipse Public License Version 1.0, which accompanies this distribution and
 * is available at http://www.eclipse.org/legal/epl-v10.html.
 */
import React from 'react';
import PureComponent from '../components/purecomponent.react';
import SuggestionResult from './suggestions-result.react';
import {onNewSuggestionQuery} from './actions';

require('./suggestions.styl')

export default class Suggestions extends PureComponent {

  handleQueryChange(event) {
    onNewSuggestionQuery(event.target.value)
  }

  render() {
    return (
      <div className={'suggestions'}>
        <div className={'query'}>
           <input onChange={this.handleQueryChange.bind(this)} value={this.props.suggestions.get("request").get("text")}/>
        </div>
        <SuggestionResult 
          result={this.props.suggestions.get("result")} 
          request={this.props.suggestions.get("request")}
        />
      </div>
    );
  }
}<commit_msg>debounce suggestion input<commit_after>/*
 * Logspace
 * Copyright (c) 2015 Indoqa Software Design und Beratung GmbH. All rights reserved.
 * This program and the accompanying materials are made available under the terms of
 * the Eclipse Public License Version 1.0, which accompanies this distribution and
 * is available at http://www.eclipse.org/legal/epl-v10.html.
 */
import React from 'react';
import PureComponent from '../components/purecomponent.react';
import SuggestionResult from './suggestions-result.react';
import {onNewSuggestionQuery} from './actions';

import debounceFunc from '../../lib/debounce'

require('./suggestions.styl')

export default class Suggestions extends PureComponent {

  constructor(props) {
    super(props);

    this.state = {
      input: props.suggestions.get("request").get("text")
    };
  }

  componentDidMount() {
    var me = this;

    this.debouncedChangeFunction = debounceFunc(function() {
      onNewSuggestionQuery(me.state.input)
    }, 350)
  }

  handleQueryChange(event) {
    this.setState({input: event.target.value});
    this.debouncedChangeFunction() 
  }

  render() {
    return (
      <div className={'suggestions'}>
        <div className={'query'}>
           <input onChange={this.handleQueryChange.bind(this)} value={this.state.input}/>
        </div>
        <SuggestionResult 
          result={this.props.suggestions.get("result")} 
          request={this.props.suggestions.get("request")}
        />
      </div>
    );
  }
}
{'fraction_non_alphanumeric': 0.12864169504351117, 'fraction_numerical': 0.007188800605372683, 'mean_word_length': 3.4288107202680065, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '136498', 'n_tokens_mistral': 793, 'n_tokens_neox': 735, 'n_words': 183}