1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Fixed empty separators in menu

This commit is contained in:
Laurent Cozic 2019-05-27 19:48:09 +01:00
parent bab3a12e92
commit fc77419ca1

View File

@ -806,6 +806,24 @@ class Application extends BaseApplication {
rootMenus.file = rootMenuFile; rootMenus.file = rootMenuFile;
} }
// It seems the "visible" property of separators is ignored by Electron, making
// it display separators that we want hidden. So this function iterates through
// them and remove them completely.
const cleanUpSeparators = items => {
const output = [];
for (const item of items) {
if ('visible' in item && item.type === 'separator' && !item.visible) continue;
output.push(item);
}
return output;
}
for (const key in rootMenus) {
if (!rootMenus.hasOwnProperty(key)) continue;
if (!rootMenus[key].submenu) continue;
rootMenus[key].submenu = cleanUpSeparators(rootMenus[key].submenu);
}
const pluginMenuItems = PluginManager.instance().menuItems(); const pluginMenuItems = PluginManager.instance().menuItems();
for (const item of pluginMenuItems) { for (const item of pluginMenuItems) {
let itemParent = rootMenus[item.parent] ? rootMenus[item.parent] : 'tools'; let itemParent = rootMenus[item.parent] ? rootMenus[item.parent] : 'tools';