Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update app menu to add items for side nav items #2965

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
113 changes: 96 additions & 17 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 @@ -1131,22 +1136,6 @@ function runApp() {
{ type: 'separator' },
{ role: 'togglefullscreen' },
{ type: 'separator' },
{
label: 'History',
// MacOS: Command + Y
// Other OS: Ctrl + H
accelerator: process.platform === 'darwin' ? 'Cmd+Y' : 'Ctrl+H',
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) { return }

browserWindow.webContents.send(
'change-view',
{ route: '/history' }
)
},
type: 'normal'
},
{ type: 'separator' },
{
label: 'Back',
accelerator: 'Alt+Left',
Expand All @@ -1173,6 +1162,96 @@ function runApp() {
},
]
},
{
label: 'Navigate',
submenu: [
{
label: 'Subscriptions',
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) {
return
}

browserWindow.webContents.send(
'change-view',
{ route: '/subscriptions' }
)
},
type: 'normal'
},
{
label: 'Channels',
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) {
return
}

browserWindow.webContents.send(
'change-view',
{ route: '/subscribedchannels' }
)
},
type: 'normal'
},
!hideTrendingVideos && {
label: 'Trending',
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) {
return
}

browserWindow.webContents.send(
'change-view',
{ route: '/trending' }
)
},
type: 'normal'
},
!hidePopularVideos && {
label: 'Most Popular',
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) {
return
}

browserWindow.webContents.send(
'change-view',
{ route: '/popular' }
)
},
type: 'normal'
},
!hidePlaylists && {
label: 'Playlists',
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) {
return
}

browserWindow.webContents.send(
'change-view',
{ route: '/userplaylists' }
)
},
type: 'normal'
},
{
label: 'History',
// MacOS: Command + Y
// Other OS: Ctrl + H
accelerator: process.platform === 'darwin' ? 'Cmd+Y' : 'Ctrl+H',
click: (_menuItem, browserWindow, _event) => {
if (browserWindow == null) { return }

browserWindow.webContents.send(
'change-view',
{ route: '/history' }
)
},
type: 'normal'
},
].filter((v) => v !== false),
},
{
role: 'window',
submenu: [
Expand Down