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

Make landing page configurable #4200

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 12 additions & 2 deletions src/renderer/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export default defineComponent({
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
},

landingPage: function() {
return '/' + this.$store.getters.getLandingPage
},

externalLinkOpeningPromptNames: function () {
return [
this.$t('Yes'),
Expand All @@ -136,7 +140,7 @@ export default defineComponent({
$route () {
// react to route changes...
// Hide top nav filter panel on page change
this.$refs.topNav.hideFilters()
this.$refs.topNav?.hideFilters()
}
},
created () {
Expand Down Expand Up @@ -178,7 +182,13 @@ export default defineComponent({
})

this.$router.afterEach((to, from) => {
this.$refs.topNav.navigateHistory()
this.$refs.topNav?.navigateHistory()
})

this.$router.onReady(() => {
if (this.$router.currentRoute.path !== this.landingPage && this.landingPage !== '/subscriptions') {
this.$router.push({ path: this.landingPage })
}
})
})
},
Expand Down
51 changes: 37 additions & 14 deletions src/renderer/components/general-settings/general-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ export default defineComponent({
'invidious',
'local'
],
defaultPageNames: [
'Subscriptions',
'Trending',
'Most Popular',
'Playlists',
'History'
],
defaultPageValues: [
'subscriptions',
'trending',
'mostPopular',
'playlists',
'history'
],
viewTypeValues: [
'grid',
'list'
Expand All @@ -56,6 +42,15 @@ export default defineComponent({
'',
'openLinkAfterPrompt',
'doNothing'
],
includedDefaultPageNames: [
'subscriptions',
'subscribedChannels',
'trending',
'popular',
'userPlaylists',
'history',
'settings'
]
}
},
Expand All @@ -75,10 +70,38 @@ export default defineComponent({
checkForBlogPosts: function () {
return this.$store.getters.getCheckForBlogPosts
},
hidePlaylists: function () {
return this.$store.getters.getHidePlaylists
},
hidePopularVideos: function () {
return this.$store.getters.getHidePopularVideos
},
hideTrendingVideos: function () {
return this.$store.getters.getHideTrendingVideos
},
defaultPages: function () {
let includedPageNames = this.includedDefaultPageNames
if (this.hideTrendingVideos) includedPageNames = includedPageNames.filter((pageName) => pageName !== 'trending')
if (this.hidePlaylists) includedPageNames = includedPageNames.filter((pageName) => pageName !== 'userPlaylists')
if (!(!this.hidePopularVideos && (this.backendFallback || this.backendPreference === 'invidious'))) includedPageNames = includedPageNames.filter((pageName) => pageName !== 'popular')
return this.$router.getRoutes().filter((route) => includedPageNames.includes(route.name))
},
defaultPageNames: function () {
return this.defaultPages.map((route) => this.$t(route.meta.title))
},
defaultPageValues: function () {
// avoid Vue parsing issues by excluding '/' from path values
return this.defaultPages.map((route) => route.path.substring(1))
},
backendPreference: function () {
return this.$store.getters.getBackendPreference
},
landingPage: function () {
const landingPage = this.$store.getters.getLandingPage
// invalidate landing page selection & restore to default value if no longer valid
if (!this.defaultPageValues.includes(landingPage)) {
this.updateLandingPage('subscriptions')
}
return this.$store.getters.getLandingPage
},
region: function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
@change="handlePreferredApiBackend"
/>
<ft-select
v-if="false"
:placeholder="$t('Settings.General Settings.Default Landing Page')"
:value="landingPage"
:select-names="defaultPageNames"
Expand Down
14 changes: 14 additions & 0 deletions src/renderer/components/top-nav/top-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ export default defineComponent({
return this.$store.getters.getHideHeaderLogo
},

landingPage: function () {
return this.$store.getters.getLandingPage
},

headerLogoTitle: function () {
return this.$t('Go to page',
{
page: this.$t(this.$router.getRoutes()
.find((route) => route.path === '/' + this.landingPage)
.meta.title
)
})
},

enableSearchSuggestions: function () {
return this.$store.getters.getEnableSearchSuggestions
},
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/top-nav/top-nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
dir="ltr"
role="link"
tabindex="0"
:title="$t('Subscriptions.Subscriptions')"
@click="navigate('subscriptions')"
@keydown.space.prevent="navigate('subscriptions')"
@keydown.enter.prevent="navigate('subscriptions')"
:title="headerLogoTitle"
@click="navigate(landingPage)"
@keydown.space.prevent="navigate(landingPage)"
@keydown.enter.prevent="navigate(landingPage)"
>
<div
class="logoIcon"
Expand Down
55 changes: 32 additions & 23 deletions src/renderer/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,64 +22,47 @@ const router = new Router({
routes: [
{
path: '/',
name: 'default',
meta: {
title: 'Subscriptions.Subscriptions'
},
component: Subscriptions
},
{
path: '/subscriptions',
name: 'subscriptions',
meta: {
title: 'Subscriptions.Subscriptions'
},
component: Subscriptions
},
{
path: '/subscribedchannels',
name: 'subscribedChannels',
meta: {
title: 'Channels.Title'
},
component: SubscribedChannels
},
{
path: '/settings/profile',
meta: {
title: 'Profile.Profile Settings'
},
component: ProfileSettings
},
{
path: '/settings/profile/new',
name: 'newProfile',
meta: {
title: 'Profile.Create New Profile'
},
component: ProfileEdit
},
{
path: '/settings/profile/edit/:id',
name: 'editProfile',
meta: {
title: 'Profile.Edit Profile'
},
component: ProfileEdit
},
{
path: '/trending',
name: 'trending',
meta: {
title: 'Trending.Trending'
},
component: Trending
},
{
path: '/popular',
name: 'popular',
meta: {
title: 'Most Popular'
},
component: Popular
},
{
path: '/userplaylists',
name: 'userPlaylists',
meta: {
title: 'User Playlists.Your Playlists'
},
Expand All @@ -95,18 +78,44 @@ const router = new Router({
},
{
path: '/settings',
name: 'settings',
meta: {
title: 'Settings.Settings'
},
component: Settings
},
{
path: '/about',
name: 'about',
meta: {
title: 'About.About'
},
component: About
},
{
path: '/settings/profile',
name: 'profileSettings',
meta: {
title: 'Profile.Profile Settings'
},
component: ProfileSettings
},
{
path: '/settings/profile/new',
name: 'newProfile',
meta: {
title: 'Profile.Create New Profile'
},
component: ProfileEdit
},
{
path: '/settings/profile/edit/:id',
name: 'editProfile',
meta: {
title: 'Profile.Edit Profile'
},
component: ProfileEdit
},
{
path: '/search/:query',
meta: {
Expand Down
1 change: 1 addition & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Close: Close
Back: Back
Forward: Forward
Open New Window: Open New Window
Go to page: Go to {page}

Version {versionNumber} is now available! Click for more details: Version {versionNumber} is now available! Click
for more details
Expand Down