From 745c435af1281523fbfb1ec98375e74e3b63f46b Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Sat, 21 Oct 2023 01:06:16 -0500 Subject: [PATCH 1/5] Implement customizable landing pages --- src/renderer/App.js | 14 ++++- .../general-settings/general-settings.js | 25 ++++----- .../general-settings/general-settings.vue | 1 - src/renderer/router/index.js | 55 +++++++++++-------- 4 files changed, 55 insertions(+), 40 deletions(-) diff --git a/src/renderer/App.js b/src/renderer/App.js index 21db0394f2e90..0063f8b98a389 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -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'), @@ -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 () { @@ -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 }) + } }) }) }, diff --git a/src/renderer/components/general-settings/general-settings.js b/src/renderer/components/general-settings/general-settings.js index ba5117ffd7584..9ebdbaee038e7 100644 --- a/src/renderer/components/general-settings/general-settings.js +++ b/src/renderer/components/general-settings/general-settings.js @@ -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' @@ -75,6 +61,17 @@ export default defineComponent({ checkForBlogPosts: function () { return this.$store.getters.getCheckForBlogPosts }, + defaultPages: function () { + // filter out default '/' route and routes with params + return this.$router.getRoutes().filter((route, i) => i !== 0 && !route.path.includes(':')) + }, + 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 }, diff --git a/src/renderer/components/general-settings/general-settings.vue b/src/renderer/components/general-settings/general-settings.vue index f949a05d4dea8..b9c47e4482e55 100644 --- a/src/renderer/components/general-settings/general-settings.vue +++ b/src/renderer/components/general-settings/general-settings.vue @@ -43,7 +43,6 @@ @change="handlePreferredApiBackend" /> Date: Sat, 21 Oct 2023 09:55:33 -0500 Subject: [PATCH 2/5] Implement curated list for default landing page dropdown options --- .../components/general-settings/general-settings.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/general-settings/general-settings.js b/src/renderer/components/general-settings/general-settings.js index 9ebdbaee038e7..b47b3324cab1b 100644 --- a/src/renderer/components/general-settings/general-settings.js +++ b/src/renderer/components/general-settings/general-settings.js @@ -42,6 +42,15 @@ export default defineComponent({ '', 'openLinkAfterPrompt', 'doNothing' + ], + includedDefaultPageNames: [ + 'subscriptions', + 'subscribedChannels', + 'trending', + 'popular', + 'userPlaylists', + 'history', + 'settings' ] } }, @@ -62,8 +71,7 @@ export default defineComponent({ return this.$store.getters.getCheckForBlogPosts }, defaultPages: function () { - // filter out default '/' route and routes with params - return this.$router.getRoutes().filter((route, i) => i !== 0 && !route.path.includes(':')) + return this.$router.getRoutes().filter((route) => this.includedDefaultPageNames.includes(route.name)) }, defaultPageNames: function () { return this.defaultPages.map((route) => this.$t(route.meta.title)) From fc00bc9e79a91195ff519e18cb28527ee7525965 Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Sat, 21 Oct 2023 14:08:44 -0500 Subject: [PATCH 3/5] Update top nav link to redirect back to selected landing page --- src/renderer/components/top-nav/top-nav.js | 10 ++++++++++ src/renderer/components/top-nav/top-nav.vue | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/top-nav/top-nav.js b/src/renderer/components/top-nav/top-nav.js index 801bb2c92da6c..c1986a1823c96 100644 --- a/src/renderer/components/top-nav/top-nav.js +++ b/src/renderer/components/top-nav/top-nav.js @@ -40,6 +40,16 @@ export default defineComponent({ return this.$store.getters.getHideHeaderLogo }, + landingPage: function () { + return this.$store.getters.getLandingPage + }, + + headerLogoTitle: function () { + return this.$t(this.$router.getRoutes() + .find((route) => route.path === '/' + this.landingPage) + .meta.title) + }, + enableSearchSuggestions: function () { return this.$store.getters.getEnableSearchSuggestions }, diff --git a/src/renderer/components/top-nav/top-nav.vue b/src/renderer/components/top-nav/top-nav.vue index 03cd544ce1ac6..69a54ab70355b 100644 --- a/src/renderer/components/top-nav/top-nav.vue +++ b/src/renderer/components/top-nav/top-nav.vue @@ -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)" >
Date: Sat, 21 Oct 2023 14:27:35 -0500 Subject: [PATCH 4/5] Update top nav title to be 'Go to {page}' for improved clarity --- src/renderer/components/top-nav/top-nav.js | 10 +++++++--- static/locales/en-US.yaml | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/top-nav/top-nav.js b/src/renderer/components/top-nav/top-nav.js index c1986a1823c96..1189b61ea4851 100644 --- a/src/renderer/components/top-nav/top-nav.js +++ b/src/renderer/components/top-nav/top-nav.js @@ -45,9 +45,13 @@ export default defineComponent({ }, headerLogoTitle: function () { - return this.$t(this.$router.getRoutes() - .find((route) => route.path === '/' + this.landingPage) - .meta.title) + return this.$t('Go to page', + { + page: this.$t(this.$router.getRoutes() + .find((route) => route.path === '/' + this.landingPage) + .meta.title + ) + }) }, enableSearchSuggestions: function () { diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index b1b6a720a6e2f..cd34db08ec931 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -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 From e22495780f4424d08712edba5e64e60e680bcdfe Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Thu, 16 Nov 2023 18:53:48 -0600 Subject: [PATCH 5/5] Remove landing page from selection and/or restore selection to default if is no longer valid --- .../general-settings/general-settings.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/renderer/components/general-settings/general-settings.js b/src/renderer/components/general-settings/general-settings.js index b47b3324cab1b..3dc6a56adaf02 100644 --- a/src/renderer/components/general-settings/general-settings.js +++ b/src/renderer/components/general-settings/general-settings.js @@ -70,8 +70,21 @@ 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 () { - return this.$router.getRoutes().filter((route) => this.includedDefaultPageNames.includes(route.name)) + 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)) @@ -84,6 +97,11 @@ export default defineComponent({ 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 () {