<commit_before>import {
  Component, DefaultDOMElement,
  platform,
} from 'substance'


export default class AppChrome extends Component {

  didMount() {
    this._init()
    DefaultDOMElement.getBrowserWindow().on('keydown', this._keyDown, this)
    DefaultDOMElement.getBrowserWindow().on('drop', this._supressDnD, this)
    DefaultDOMElement.getBrowserWindow().on('dragover', this._supressDnD, this)
  }

  dispose() {
    DefaultDOMElement.getBrowserWindow().off(this)
  }

  getChildContext() {
    return this._childContext
  }

  getInitialState() {
    return {
      archive: undefined,
      error: undefined
    }
  }

  /*
    4 initialisation stages

    - _setupChildContext (sync)
    - _initContext (async)
    - _loadArchive (async)
    - _initArchive (async)
  */
  _init() {
    this._childContext = this._setupChildContext()

    let promise = this._initContext(this._childContext)
    .then(() => this._loadArchive(this.props.archiveId, this._childContext))
    .then(archive => this._initArchive(archive, this._childContext))
    .then(archive => {
      this.setState({archive})
    })

    if (!platform.devtools) {
      promise.catch(error => {
        console.error(error)
        this.setState({error})
      })
    }
  }

  _setupChildContext() {
    return this.context
  }

  _initContext(context) {
    return Promise.resolve(context)
  }

  _loadArchive() {
    throw new Error('_loadArchive not implemented')
  }

  _initArchive(archive) {
    return Promise.resolve(archive)
  }

  /*
    We may want an explicit save button, that can be configured on app level,
    but passed down to editor toolbars.
  */
  _save() {
    this.state.archive.save().then(() => {
      this._updateTitle(false)
    }).catch(err => {
      console.error(err)
    })
  }

  _updateTitle() {
    // no-op
  }
<commit_msg>let AppChrome._save() return a Promise.<commit_after>import {
  Component, DefaultDOMElement,
  platform,
} from 'substance'


export default class AppChrome extends Component {

  didMount() {
    this._init()
    DefaultDOMElement.getBrowserWindow().on('keydown', this._keyDown, this)
    DefaultDOMElement.getBrowserWindow().on('drop', this._supressDnD, this)
    DefaultDOMElement.getBrowserWindow().on('dragover', this._supressDnD, this)
  }

  dispose() {
    DefaultDOMElement.getBrowserWindow().off(this)
  }

  getChildContext() {
    return this._childContext
  }

  getInitialState() {
    return {
      archive: undefined,
      error: undefined
    }
  }

  /*
    4 initialisation stages

    - _setupChildContext (sync)
    - _initContext (async)
    - _loadArchive (async)
    - _initArchive (async)
  */
  _init() {
    this._childContext = this._setupChildContext()

    let promise = this._initContext(this._childContext)
    .then(() => this._loadArchive(this.props.archiveId, this._childContext))
    .then(archive => this._initArchive(archive, this._childContext))
    .then(archive => {
      this.setState({archive})
    })

    if (!platform.devtools) {
      promise.catch(error => {
        console.error(error)
        this.setState({error})
      })
    }
  }

  _setupChildContext() {
    return this.context
  }

  _initContext(context) {
    return Promise.resolve(context)
  }

  _loadArchive() {
    throw new Error('_loadArchive not implemented')
  }

  _initArchive(archive) {
    return Promise.resolve(archive)
  }

  /*
    We may want an explicit save button, that can be configured on app level,
    but passed down to editor toolbars.
  */
  _save() {
    return this.state.archive.save().then(() => {
      this._updateTitle(false)
    }).catch(err => {
      console.error(err)
    })
  }

  _updateTitle() {
    // no-op
  }

{'fraction_non_alphanumeric': 0.1272580210299272, 'fraction_numerical': 0.0005392289026691831, 'mean_word_length': 2.9468085106382977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6839752', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1146, 'n_words': 217}