Skip to content

Commit

Permalink
Fix IPC Serialization Loop (#2700)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskerr authored and philrz committed Mar 6, 2023
1 parent b80ce29 commit 3016da4
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/core/menu/built-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,24 @@ export class BuiltMenu {
}

toElectron(): MenuItemConstructorOptions[] {
const opts = this.template
for (let opt of opts) {
if ("command" in opt) {
const command = opt.command
opt.click =
return this.template.map((opt) => {
const {command, nestedMenu, checked, ...rest} = opt
let option: MenuItemConstructorOptions = {...(rest as any)}
if (command) {
option.click =
command instanceof BoundCommand
? () => command.run()
: () => commands.run(command)
}
if ("nestedMenu" in opt) {
if (opt.nestedMenu instanceof Menu) {
// @ts-ignore
opt.submenu = menus.build(opt.nestedMenu.id)
if (nestedMenu) {
if (nestedMenu instanceof Menu) {
option.submenu = menus.build(nestedMenu.id)
}
}
if ("checked" in opt) {
// @ts-ignore
opt.type = "checkbox"
if (checked !== undefined) {
option.type = "checkbox"
}
}
return opts as MenuItemConstructorOptions[]
return option
})
}
}

0 comments on commit 3016da4

Please sign in to comment.