<commit_before>import React, { Component } from 'react';
import { writeText } from '../../lib/util';

export class Settings extends Component {
  constructor(props){
    super(props);
    this.state = {
      title: "",
      description: "",
      comments: false,
      disabled: false
    }
    this.deleteNotebook = this.deleteNotebook.bind(this);
    this.changeTitle = this.changeTitle.bind(this);
    this.changeDescription = this.changeDescription.bind(this);
    this.changeComments = this.changeComments.bind(this);
  }

  componentDidMount() {
    const { props } = this;
    if (props.notebook) {
      this.setState({
        title: props.notebook.title,
        description: props.notebook.about,
        comments: props.notebook.comments
      })
    }
  }

  componentDidUpdate(prevProps) {
    const { props } = this;
    if (prevProps !== this.props) {
      if (props.notebook) {
        this.setState({
          title: props.notebook.title,
          description: props.notebook.about,
          comments: props.notebook.comments
        })
      }
    }
  }

  changeTitle(event) {
    this.setState({title: event.target.value});
  }

  changeDescription(event) {
    this.setState({description: event.target.value});
  }

  changeComments() {
    this.setState({comments: !this.state.comments}, (() => {
      window.api.setSpinner(true);
      window.api.action("publish", "publish-action", {
        "edit-book": {
          book: this.props.book,
          title: this.props.notebook.title,<commit_msg>publish: atomically refresh our settings inputs<commit_after>import React, { Component } from 'react';
import { writeText } from '../../lib/util';

export class Settings extends Component {
  constructor(props){
    super(props);
    this.state = {
      title: "",
      description: "",
      comments: false,
      disabled: false
    }
    this.deleteNotebook = this.deleteNotebook.bind(this);
    this.changeTitle = this.changeTitle.bind(this);
    this.changeDescription = this.changeDescription.bind(this);
    this.changeComments = this.changeComments.bind(this);
  }

  componentDidMount() {
    const { props } = this;
    if (props.notebook) {
      this.setState({
        title: props.notebook.title,
        description: props.notebook.about,
        comments: props.notebook.comments
      })
    }
  }

  componentDidUpdate(prevProps) {
    const { props } = this;
    if (prevProps !== props) {
      if (props.notebook) {
        if (prevProps.notebook && prevProps.notebook !== props.notebook) {
          if (prevProps.notebook.title !== props.notebook.title) {
            this.setState({title: props.notebook.title});
          }
          if (prevProps.notebook.about !== props.notebook.about) {
            this.setState({description: props.notebook.about});
          }
          if (prevProps.notebook.comments !== props.notebook.comments) {
            this.setState({comments: props.notebook.comments})
          }
        }
      }
    }
  }

  changeTitle(event) {
    this.setState({title: event.target.value});
  }

  changeDescription(event) {
    this.setState({description: event.target.value});
  }

  changeComments() {
    this.setState({comments: !this.state.comments}, (() => {
      window.api.setSpinner(true);
      window.api.action("publish", "publish-action", {
        "edit-book": {
          book: this.props.book,
          title: this.props.notebook.title,
{'fraction_non_alphanumeric': 0.13944687045123727, 'fraction_numerical': 0.0, 'mean_word_length': 2.556935817805383, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '3104707', 'n_tokens_mistral': 1016, 'n_tokens_neox': 1013, 'n_words': 170}