diff --git a/src/datastores/handlers/base.js b/src/datastores/handlers/base.js index 1250052510cb1..285307017abf9 100644 --- a/src/datastores/handlers/base.js +++ b/src/datastores/handlers/base.js @@ -31,6 +31,14 @@ class Settings { return db.settings.findOne({ _id: 'baseTheme' }) } + static _findSidenavSettings() { + return { + hideTrendingVideos: db.settings.findOne({ _id: 'hideTrendingVideos' }), + hidePopularVideos: db.settings.findOne({ _id: 'hidePopularVideos' }), + hidePlaylists: db.settings.findOne({ _id: 'hidePlaylists' }), + } + } + static _updateBounds(value) { return db.settings.update({ _id: 'bounds' }, { _id: 'bounds', value }, { upsert: true }) } diff --git a/src/main/index.js b/src/main/index.js index 3d71f0d32ce6c..c3306bbaa290e 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1043,7 +1043,12 @@ function runApp() { mainWindow.webContents.send('change-view', data) } - function setMenu() { + async function setMenu() { + const sidenavSettings = baseHandlers.settings._findSidenavSettings() + const hideTrendingVideos = (await sidenavSettings.hideTrendingVideos).value + const hidePopularVideos = (await sidenavSettings.hidePopularVideos).value + const hidePlaylists = (await sidenavSettings.hidePlaylists).value + const template = [ { label: 'File', @@ -1188,7 +1193,7 @@ function runApp() { }, type: 'normal' }, - { + !hideTrendingVideos && { label: 'Trending', click: (_menuItem, browserWindow, _event) => { if (browserWindow == null) { @@ -1202,7 +1207,7 @@ function runApp() { }, type: 'normal' }, - { + !hidePopularVideos && { label: 'Most Popular', click: (_menuItem, browserWindow, _event) => { if (browserWindow == null) { @@ -1216,7 +1221,7 @@ function runApp() { }, type: 'normal' }, - { + !hidePlaylists && { label: 'Playlists', click: (_menuItem, browserWindow, _event) => { if (browserWindow == null) { @@ -1245,7 +1250,7 @@ function runApp() { }, type: 'normal' }, - ], + ].filter((v) => v !== false), }, { role: 'window',