<commit_before>import { ipcRenderer } from 'electron';
import { TitleBar } from '@meetfranz/electron-react-titlebar';
import React, { Component } from 'react';
import { intlShape } from 'react-intl';
import { WINDOWS_TITLEBAR_FETCH_MENU, WINDOWS_TITLEBAR_RESIZE } from '../../ipcChannels';
import { AppMenu } from '../../lib/Menu';
import { DEFAULT_WEB_CONTENTS_ID } from '../../config';

export default class WindowsTitlebar extends Component {
  static contextTypes = {
    intl: intlShape,
  };

  appMenu = new AppMenu()

  componentDidMount() {
    console.log('component did mount');
    const { intl } = this.context;

    this.appMenu.setIntl(intl);

    ipcRenderer.on(WINDOWS_TITLEBAR_FETCH_MENU, (e, data) => {
      this.appMenu.update(data);
    });

    ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, WINDOWS_TITLEBAR_FETCH_MENU);
  }

  render() {
    return (
      <TitleBar
        menu={this.appMenu.menu}
        icon="assets/images/logo.svg"
        onToggleMenuBar={(isClicked) => {
          ipcRenderer.send(WINDOWS_TITLEBAR_RESIZE, {
            height: isClicked ? window.outerHeight : 28,
          });
        }}
      />
    );
  }
}<commit_msg>update titlebar component on menu change<commit_after>import { ipcRenderer } from 'electron';
import { TitleBar } from '@meetfranz/electron-react-titlebar';
import React, { Component } from 'react';
import { intlShape } from 'react-intl';
import { WINDOWS_TITLEBAR_FETCH_MENU, WINDOWS_TITLEBAR_RESIZE } from '../../ipcChannels';
import { AppMenu } from '../../lib/Menu';
import { DEFAULT_WEB_CONTENTS_ID } from '../../config';

export default class WindowsTitlebar extends Component {
  static contextTypes = {
    intl: intlShape,
  };

  state = {
    menu: [],
  }

  appMenu = new AppMenu()

  componentDidMount() {
    console.log('component did mount');
    const { intl } = this.context;

    this.appMenu.setIntl(intl);

    ipcRenderer.on(WINDOWS_TITLEBAR_FETCH_MENU, (e, data) => {
      this.appMenu.update(data);

      this.setState({
        menu: this.appMenu.menu,
      });
    });

    ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, WINDOWS_TITLEBAR_FETCH_MENU);
  }

  render() {
    return (
      <TitleBar
        menu={this.state.menu}
        icon="assets/images/logo.svg"
        onToggleMenuBar={(isClicked) => {
          ipcRenderer.send(WINDOWS_TITLEBAR_RESIZE, {
            height: isClicked ? window.outerHeight : 28,
          });
        }}
      />
    );
  }
}
{'fraction_non_alphanumeric': 0.1359577922077922, 'fraction_numerical': 0.0016233766233766235, 'mean_word_length': 2.9822294022617126, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2962059', 'n_tokens_mistral': 875, 'n_tokens_neox': 820, 'n_words': 146}