Skip to content

Commit

Permalink
Update menu instance on theme change
Browse files Browse the repository at this point in the history
  • Loading branch information
inukshuk committed Jun 2, 2020
1 parent b22bf72 commit 817ebce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/browser/menu.js
Expand Up @@ -321,6 +321,18 @@ class AppMenu extends Menu {
old.destroy()
}
}

setTheme(theme = this.app.state.theme) {
let menu = M.getApplicationMenu()
let themes = menu?.getMenuItemById('theme')

if (themes?.submenu) {
for (let item of themes.submenu.items) {
item.checked = item.id === theme
item.enabled = !item.checked
}
}
}
}

class ContextMenu extends Menu {
Expand Down
3 changes: 1 addition & 2 deletions src/browser/tropy.js
Expand Up @@ -570,7 +570,6 @@ class Tropy extends EventEmitter {
this.state.locale = locale
await this.load()
this.updateWindowLocale()
this.emit('app:reload-menu')
})

this.on('app:toggle-debug-flag', () => {
Expand Down Expand Up @@ -935,7 +934,7 @@ class Tropy extends EventEmitter {
contrast: nativeTheme.shouldUseHighContrastColors
})

this.emit('app:reload-menu')
this.menu.setTheme(theme)
}

dispatch(action, win = BrowserWindow.getFocusedWindow()) {
Expand Down

0 comments on commit 817ebce

Please sign in to comment.