Skip to content

Commit

Permalink
* Show app menu items accoridng to user settings
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuEXE committed Dec 16, 2022
1 parent 6115d3a commit 55230c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/datastores/handlers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
Expand Down
15 changes: 10 additions & 5 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -1188,7 +1193,7 @@ function runApp() {
},
type: 'normal'
},
{
!hideTrendingVideos && {
label: 'Trending',
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) {
Expand All @@ -1202,7 +1207,7 @@ function runApp() {
},
type: 'normal'
},
{
!hidePopularVideos && {
label: 'Most Popular',
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) {
Expand All @@ -1216,7 +1221,7 @@ function runApp() {
},
type: 'normal'
},
{
!hidePlaylists && {
label: 'Playlists',
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) {
Expand Down Expand Up @@ -1245,7 +1250,7 @@ function runApp() {
},
type: 'normal'
},
],
].filter((v) => v !== false),
},
{
role: 'window',
Expand Down

0 comments on commit 55230c7

Please sign in to comment.