<commit_before>import React from 'react';

import CameraStore from '../../stores/CameraStore';

import {
  takePicture,
  savePicture,
  deletePicture
} from '../../actions/CameraActions';

function getCameraState() {
  return {
    path: CameraStore.getPath()
  };
}

export default class Camera extends React.Component {

  state = getCameraState();

  componentDidMount() {
    CameraStore.addChangeListener(this.onChange);
  }

  componentWillUnmount() {
    CameraStore.removeChangeListener(this.onChange);
  }

  onChange = () => {
    this.setState(getCameraState());
  }

  hasPicture() {
    return !!this.state.path;
  }

  renderCamera() {
    return (
      <div>
         <button onClick={takePicture}>Take picture</button>
      </div>
    );
  }

  renderSaveOrDelete() {
    return (
      <div>
        <img src={this.state.path}></img>
        <button onClick={() => savePicture(this.state.path)}>Save picture</button>
        <button onClick={() => deletePicture(this.state.path)}>Delete picture</button>
      </div>
    );
  }

  render() {
    if (!this.hasPicture()) {
      return this.renderCamera();
    } else {
      return this.renderSaveOrDelete();
    }
  }
}<commit_msg>feat: add video streaming<commit_after>import React from 'react';

import CameraStore from '../../stores/CameraStore';

import {
  takePicture,
  savePicture,
  deletePicture
} from '../../actions/CameraActions';

function getCameraState() {
  return {
    path: CameraStore.getPath()
  };
}

const streamPath = 'http://172.16.17.32:8091/?action=stream';

export default class Camera extends React.Component {

  state = getCameraState();

  componentDidMount() {
    CameraStore.addChangeListener(this.onChange);
  }

  componentWillUnmount() {
    CameraStore.removeChangeListener(this.onChange);
  }

  onChange = () => {
    this.setState(getCameraState());
  }

  hasPicture() {
    return !!this.state.path;
  }

  renderCamera() {
    return (
      <div>
         <img src={streamPath} />
         <button onClick={takePicture}>Take picture</button>
      </div>
    );
  }

  renderSaveOrDelete() {
    return (
      <div>
        <img src={this.state.path} />
        <button onClick={() => savePicture(this.state.path)}>Save picture</button>
        <button onClick={() => deletePicture(this.state.path)}>Delete picture</button>
      </div>
    );
  }

  render() {
    if (!this.hasPicture()) {
      return this.renderCamera();
    } else {
      return this.renderSaveOrDelete();
    }
  }
}
{'fraction_non_alphanumeric': 0.1542447190115584, 'fraction_numerical': 0.0051813471502590676, 'mean_word_length': 2.9035769828926905, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '4017955', 'n_tokens_mistral': 799, 'n_tokens_neox': 769, 'n_words': 138}