mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-15 05:42:17 -08:00
fix: menu label is null when i18n failed to load by other bugs
this fixes https://github.com/tiddly-gittly/TiddlyGit-Desktop/issues/75
This commit is contained in:
parent
c116ea40ea
commit
fd72bf5a57
1 changed files with 4 additions and 3 deletions
|
|
@ -60,12 +60,12 @@ export class MenuService implements IMenuService {
|
|||
* You don't need to call this after calling method like insertMenu, it will be call automatically.
|
||||
*/
|
||||
public async buildMenu(): Promise<void> {
|
||||
const latestTemplate = (await this.getCurrentMenuItemConstructorOptions(this.menuTemplate)) ?? [];
|
||||
try {
|
||||
const latestTemplate = (await this.getCurrentMenuItemConstructorOptions(this.menuTemplate)) ?? [];
|
||||
const menu = Menu.buildFromTemplate(latestTemplate);
|
||||
Menu.setApplicationMenu(menu);
|
||||
} catch (error) {
|
||||
logger.error(`buildMenu() failed ${(error as Error).message} ${(error as Error).stack ?? ''}`);
|
||||
logger.error(`buildMenu() failed: ${(error as Error).message} ${(error as Error).stack ?? ''}\n${JSON.stringify(latestTemplate)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,8 @@ export class MenuService implements IMenuService {
|
|||
return await Promise.all(
|
||||
submenu.map(async (item) => ({
|
||||
...item,
|
||||
label: typeof item.label === 'function' ? item.label() : item.label,
|
||||
/** label sometimes is null, causing */
|
||||
label: typeof item.label === 'function' ? item.label() ?? undefined : item.label,
|
||||
checked: typeof item.checked === 'function' ? await item.checked() : item.checked,
|
||||
enabled: typeof item.enabled === 'function' ? await item.enabled() : item.enabled,
|
||||
submenu:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue