@@ -32,6 +32,10 @@ function buildCheckbox (key, label) {
32
32
// they natively work as soon as the menu opens. They don't work like that on Windows
33
33
// or other OSes and must be registered globally. They still collide with global
34
34
// accelerator. Please see ../utils/setup-global-shortcut.js for more info.
35
+ /**
36
+ *
37
+ * @returns {Promise<Omit<Electron.Menu, 'getMenuItemById'> & {getMenuItemById: (id: string) => Electron.MenuItem}> }
38
+ */
35
39
async function buildMenu ( ) {
36
40
const ctx = getCtx ( )
37
41
const restartIpfs = ctx . getFn ( 'restartIpfs' )
@@ -40,6 +44,7 @@ async function buildMenu () {
40
44
const launchWebUI = ctx . getFn ( 'launchWebUI' )
41
45
const manualCheckForUpdates = ctx . getFn ( 'manualCheckForUpdates' )
42
46
47
+ // @ts -expect-error
43
48
return Menu . buildFromTemplate ( [
44
49
// @ts -ignore
45
50
...[
@@ -259,7 +264,6 @@ const setupMenu = async () => {
259
264
const ctx = getCtx ( )
260
265
const updateMenu = ctx . getFn ( 'tray.update-menu' )
261
266
const menu = await buildMenu ( )
262
- ctx . setProp ( 'tray-menu' , menu )
263
267
264
268
tray . setContextMenu ( menu )
265
269
tray . setToolTip ( 'IPFS Desktop' )
@@ -309,7 +313,7 @@ module.exports = async function () {
309
313
const ctx = getCtx ( )
310
314
const { status, gcRunning, isUpdating } = await ctx . getProp ( 'tray-menu-state' )
311
315
const errored = status === STATUS . STARTING_FAILED || status === STATUS . STOPPING_FAILED
312
- const menu = await ctx . getProp ( 'tray-menu' )
316
+ const menu = await buildMenu ( )
313
317
314
318
menu . getMenuItemById ( 'ipfsIsStarting' ) . visible = status === STATUS . STARTING_STARTED && ! gcRunning && ! isUpdating
315
319
menu . getMenuItemById ( 'ipfsIsRunning' ) . visible = status === STATUS . STARTING_FINISHED && ! gcRunning && ! isUpdating
@@ -396,7 +400,7 @@ module.exports = async function () {
396
400
} )
397
401
398
402
ipcMain . on ( ipcMainEvents . CONFIG_UPDATED , ( ) => { updateMenu ( ) } )
399
- ipcMain . on ( ipcMainEvents . LANG_UPDATED , async ( ) => { await setupMenu ( ) } )
403
+ ipcMain . on ( ipcMainEvents . LANG_UPDATED , ( ) => { updateMenu ( ) } )
400
404
401
405
nativeTheme . on ( 'updated' , ( ) => {
402
406
updateMenu ( )
0 commit comments