Have executeMenuItem take a MenuItem instance

This commit is contained in:
Markus Olsson 2016-11-30 12:38:53 +01:00
parent fce61599c9
commit 38d5a5cd91
3 changed files with 10 additions and 10 deletions

View file

@ -14,7 +14,7 @@ import { GitHubRepository } from '../../models/github-repository'
import { ICommitMessage } from './git-store'
import { v4 as guid } from 'node-uuid'
import { executeMenuItem } from '../../ui/main-process-proxy'
import { AppMenu } from '../../models/app-menu'
import { AppMenu, MenuItem } from '../../models/app-menu'
/**
* Extend Error so that we can create new Errors with a callstack different from
@ -428,8 +428,10 @@ export class Dispatcher {
return this.appStore._setAppMenuState(update)
}
public executeMenuItem(id: string): Promise<void> {
executeMenuItem(id)
/**
*/
public executeMenuItem(item: MenuItem): Promise<void> {
executeMenuItem(item)
return Promise.resolve()
}
}

View file

@ -49,7 +49,7 @@ export class AppMenu extends React.Component<IAppMenuProps, void> {
if (item.type === 'submenuItem') {
this.props.dispatcher.setAppMenuState(menu => menu.withOpenMenu(item))
} else {
this.props.dispatcher.executeMenuItem(item.id)
this.props.dispatcher.executeMenuItem(item)
this.props.onClose()
}
}

View file

@ -1,5 +1,6 @@
import { ipcRenderer } from 'electron'
import { MenuIDs } from '../main-process/menu'
import { MenuItem } from '../models/app-menu'
/** Set the menu item's enabledness. */
export function setMenuEnabled(id: MenuIDs, enabled: boolean) {
@ -16,12 +17,9 @@ export function sendReady(time: number) {
ipcRenderer.send('renderer-ready', time)
}
/**
* Tell the main process to execute (i.e. simulate a click of)
* the menu item referred to by the id parameter.
*/
export function executeMenuItem(id: string) {
ipcRenderer.send('execute-menu-item', { id })
/** Tell the main process to execute (i.e. simulate a click of) the menu item. */
export function executeMenuItem(item: MenuItem) {
ipcRenderer.send('execute-menu-item', { id: item.id })
}
export interface IMenuItem {