<commit_before>import * as React from 'react'
import { MenuPane } from './menu-pane'
import { Dispatcher } from '../../lib/dispatcher'
import { IMenuWithSelection } from '../../lib/app-state'
import { SelectionSource } from '../list'

interface IAppMenuProps {
  readonly state: ReadonlyArray<IMenuWithSelection>
  readonly dispatcher: Dispatcher
  readonly onClose: () => void
}

export class AppMenu extends React.Component<IAppMenuProps, void> {

  /**
   * The index of the menu pane that should receive focus after the
   * next render. Default value is -1. This field is cleared after
   * each successful focus operation.
   */
  private focusPane: number = - 1

  /**
   * A mapping between pane index (depth) and actual MenuPane instances.
   * This is used in order to (indirectly) call the focus method on the
   * underlying List instances.
   *
   * See focusPane and ensurePaneFocus
   */
  private paneRefs: MenuPane[] = []

  /**
   * A numeric reference to a setTimeout timer id which is used for
   * opening and closing submenus after a delay.
   *
   * See scheduleExpand and scheduleCollapse
   */
  private expandCollapseTimer: number | null = null

  public constructor(props: IAppMenuProps) {
    super(props)
    this.focusPane = props.state.length - 1
  }

  private onItemClicked = (depth: number, item: Electron.MenuItem) => {
    if (item.type === 'submenu') {
      this.expandSubmenu(depth, item)
    } else {
      // TODO: This is where the magic should happen
      const id = (item as any).id
      if (id) {
        this.props.dispatcher.executeMenuItem(id)
        this.props.onClose()
      }
    }<commit_msg>:fire: old comment<commit_after>import * as React from 'react'
import { MenuPane } from './menu-pane'
import { Dispatcher } from '../../lib/dispatcher'
import { IMenuWithSelection } from '../../lib/app-state'
import { SelectionSource } from '../list'

interface IAppMenuProps {
  readonly state: ReadonlyArray<IMenuWithSelection>
  readonly dispatcher: Dispatcher
  readonly onClose: () => void
}

export class AppMenu extends React.Component<IAppMenuProps, void> {

  /**
   * The index of the menu pane that should receive focus after the
   * next render. Default value is -1. This field is cleared after
   * each successful focus operation.
   */
  private focusPane: number = - 1

  /**
   * A mapping between pane index (depth) and actual MenuPane instances.
   * This is used in order to (indirectly) call the focus method on the
   * underlying List instances.
   *
   * See focusPane and ensurePaneFocus
   */
  private paneRefs: MenuPane[] = []

  /**
   * A numeric reference to a setTimeout timer id which is used for
   * opening and closing submenus after a delay.
   *
   * See scheduleExpand and scheduleCollapse
   */
  private expandCollapseTimer: number | null = null

  public constructor(props: IAppMenuProps) {
    super(props)
    this.focusPane = props.state.length - 1
  }

  private onItemClicked = (depth: number, item: Electron.MenuItem) => {
    if (item.type === 'submenu') {
      this.expandSubmenu(depth, item)
    } else {
      const id = (item as any).id
      if (id) {
        this.props.dispatcher.executeMenuItem(id)
        this.props.onClose()
      }
    }
{'fraction_non_alphanumeric': 0.10252463054187193, 'fraction_numerical': 0.0018472906403940886, 'mean_word_length': 3.011111111111111, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '5194147', 'n_tokens_mistral': 952, 'n_tokens_neox': 926, 'n_words': 326}