-
Notifications
You must be signed in to change notification settings - Fork 15
Add ability to send event to UI to rerender menu #565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
batrudinych
merged 8 commits into
bitfinexcom:staging
from
ZIMkaRU:feature/add-ability-to-send-event-to-ui-to-rerender-menu
Nov 11, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dfac7de
Add method to send rerender menu event
ZIMkaRU c6bbc14
Expose onRerenderMenuEvent to ui
ZIMkaRU 2a6fcde
Get unified win names for win availability checker
ZIMkaRU 355e530
Add util to change menu item states by id
ZIMkaRU db0ee8a
Add ability to bulk change menu item states by id
ZIMkaRU 734c4a2
Send rerender menu event in case of auto update
ZIMkaRU f6086cd
Send rerender menu event in case of showing changelog
ZIMkaRU f4ec9dc
Send rerender menu event in case of showing error dialog
ZIMkaRU File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| 'use strict' | ||
|
|
||
| const { Menu, MenuItem } = require('electron') | ||
|
|
||
| const MenuIpcChannelHandlers = require( | ||
| '../../window-creators/main-renderer-ipc-bridge/menu-ipc-channel-handlers' | ||
| ) | ||
| const wins = require('../../window-creators/windows') | ||
| const WINDOW_NAMES = require('../../window-creators/window.names') | ||
| const isMainWinAvailable = require( | ||
| '../../helpers/is-main-win-available' | ||
| ) | ||
|
|
||
| module.exports = (menuItemId, opts) => { | ||
| const menu = Menu.getApplicationMenu() | ||
| const args = Array.isArray(menuItemId) | ||
| ? menuItemId | ||
| : [{ menuItemId, opts }] | ||
|
|
||
| if ( | ||
| !(menu instanceof Menu) || | ||
| args.length === 0 | ||
| ) { | ||
| return | ||
| } | ||
|
|
||
| for (const item of args) { | ||
| const id = item?.menuItemId | ||
| const props = { | ||
| ...item?.opts, | ||
| ...opts | ||
| } | ||
|
|
||
| if (!id) { | ||
| continue | ||
| } | ||
|
|
||
| const menuItem = id instanceof MenuItem | ||
| ? id | ||
| : menu.getMenuItemById(id) | ||
|
|
||
| for (const [name, val] of Object.entries(props)) { | ||
| menuItem[name] = val | ||
| } | ||
| } | ||
|
|
||
| if (!isMainWinAvailable()) { | ||
| return | ||
| } | ||
|
|
||
| MenuIpcChannelHandlers | ||
| .sendRerenderMenuEvent(wins[WINDOW_NAMES.MAIN_WINDOW]) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use strict' | ||
|
|
||
| const changeMenuItemStatesById = require( | ||
| './change-menu-item-states-by-id' | ||
| ) | ||
|
|
||
| module.exports = { | ||
| changeMenuItemStatesById | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest always accepting an array
([{ menuItemId, opts }, ...], fallbackOpts)in this method since we create an array from a single item anyway. IMHO, parameters list is misleading otherwise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not against strict typing, but I'd like to keep some flexibility here as it is
Since this is pure JS, we should rely on the
Defensive Programming, and this is an old and reliable way of guaranteeing an array in this placeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am up for different styles and paradigms. I'm this particular case I'm missing the purpose of m multiple types accepted since it always creates an array anyway. At the same time, there is only one place where method is invoked with an array and it could be easily modified to have multiple calls instead. Additionally,
optslogic with the current approach is not straightforward and serves multiple purposes simultaneously, which is not ideal.After all, to me the current implementation looks unnecessarily overcomplicated, which translates to maintenance problems eventually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified to have multiple calls insteadnot quite so as at the end, we should emit one rerender menu event