Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
133 changes: 116 additions & 17 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,17 @@ function runApp() {
event,
{ event: SyncEvents.GENERAL.UPSERT, data }
)
switch (data._id) {
// Update app menu on related setting update
case 'hideTrendingVideos':
case 'hidePopularVideos':
case 'hidePlaylists':
await setMenu()
break

default:
// Do nothing for unmatched settings
}
return null

default:
Expand Down Expand Up @@ -1043,7 +1054,21 @@ function runApp() {
mainWindow.webContents.send('change-view', data)
}

function setMenu() {
async function setMenu() {
const sidenavSettings = baseHandlers.settings._findSidenavSettings()
let hideTrendingVideos = false
try {
hideTrendingVideos = (await sidenavSettings.hideTrendingVideos).value
} catch {}
let hidePopularVideos = false
try {
hidePopularVideos = (await sidenavSettings.hidePopularVideos).value
} catch {}
let hidePlaylists = false
try {
hidePlaylists = (await sidenavSettings.hidePlaylists).value
} catch {}
Comment thread
PikachuEXE marked this conversation as resolved.
Outdated

const template = [
{
label: 'File',
Expand Down Expand Up @@ -1131,22 +1156,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 +1182,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