From 5e6f58f43704402b601cfb8321ce6f0e3c88b1c4 Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Sat, 18 Nov 2023 16:51:00 -0600 Subject: [PATCH 1/3] Implement 'show latest video from channel' feature --- .../subscription-settings.js | 6 +++++- .../subscription-settings.vue | 6 ++++++ src/renderer/helpers/subscriptions.js | 21 +++++++++++++++---- src/renderer/store/modules/settings.js | 1 + static/locales/en-US.yaml | 1 + 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/renderer/components/subscription-settings/subscription-settings.js b/src/renderer/components/subscription-settings/subscription-settings.js index 303a5d20cf152..19404a4d69caa 100644 --- a/src/renderer/components/subscription-settings/subscription-settings.js +++ b/src/renderer/components/subscription-settings/subscription-settings.js @@ -13,6 +13,9 @@ export default defineComponent({ hideWatchedSubs: function () { return this.$store.getters.getHideWatchedSubs }, + onlyShowLatestFromChannel: function () { + return this.$store.getters.getOnlyShowLatestFromChannel + }, useRssFeeds: function () { return this.$store.getters.getUseRssFeeds }, @@ -24,7 +27,8 @@ export default defineComponent({ ...mapActions([ 'updateHideWatchedSubs', 'updateUseRssFeeds', - 'updateFetchSubscriptionsAutomatically' + 'updateFetchSubscriptionsAutomatically', + 'updateOnlyShowLatestFromChannel' ]) } }) diff --git a/src/renderer/components/subscription-settings/subscription-settings.vue b/src/renderer/components/subscription-settings/subscription-settings.vue index ad6269f8a0eab..3873fe40261cb 100644 --- a/src/renderer/components/subscription-settings/subscription-settings.vue +++ b/src/renderer/components/subscription-settings/subscription-settings.vue @@ -26,6 +26,12 @@ :compact="true" @change="updateHideWatchedSubs" /> + diff --git a/src/renderer/helpers/subscriptions.js b/src/renderer/helpers/subscriptions.js index 8ee8d78d8f2ba..143c38f6cd7f8 100644 --- a/src/renderer/helpers/subscriptions.js +++ b/src/renderer/helpers/subscriptions.js @@ -8,10 +8,19 @@ import { calculatePublishedDate } from './utils' export function updateVideoListAfterProcessing(videos) { let videoList = videos - // Filtering and sorting based in preference - videoList.sort((a, b) => { - return b.publishedDate - a.publishedDate - }) + if (store.getters.getOnlyShowLatestFromChannel) { + const authors = new Set() + videoList = videoList.filter((video) => { + if (!video.authorId) { + return true + } else if (!authors.has(video.authorId)) { + authors.add(video.authorId) + return true + } + + return false + }) + } if (store.getters.getHideLiveStreams) { videoList = videoList.filter(item => { @@ -45,6 +54,10 @@ export function updateVideoListAfterProcessing(videos) { }) } + videoList.sort((a, b) => { + return b.publishedDate - a.publishedDate + }) + return videoList } diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index ba2ff912b1218..61159a094d1d3 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -229,6 +229,7 @@ const state = { landingPage: 'subscriptions', listType: 'grid', maxVideoPlaybackRate: 3, + onlyShowLatestFromChannel: false, playNextVideo: false, proxyHostname: '127.0.0.1', proxyPort: '9050', diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index 320dd5735920d..dc0eafbfbbd30 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -337,6 +337,7 @@ Settings: Fetch Feeds from RSS: Fetch Feeds from RSS Manage Subscriptions: Manage Subscriptions Fetch Automatically: Fetch Feed Automatically + Only Show Latest Video from Channel: Only Show Latest Video from Channel Distraction Free Settings: Distraction Free Settings: Distraction Free Settings Sections: From 8da8706a4d9ea30f8744a045a42f1ab70346f6f2 Mon Sep 17 00:00:00 2001 From: Jason <84899178+jasonhenriquez@users.noreply.github.com> Date: Tue, 21 Nov 2023 07:14:06 +0000 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: PikachuEXE --- .../components/subscription-settings/subscription-settings.vue | 2 +- static/locales/en-US.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/subscription-settings/subscription-settings.vue b/src/renderer/components/subscription-settings/subscription-settings.vue index 3873fe40261cb..090e39c875638 100644 --- a/src/renderer/components/subscription-settings/subscription-settings.vue +++ b/src/renderer/components/subscription-settings/subscription-settings.vue @@ -27,7 +27,7 @@ @change="updateHideWatchedSubs" /> Date: Sat, 25 Nov 2023 11:34:37 -0600 Subject: [PATCH 3/3] Adjust ordering to maximize chance of content being presented --- src/renderer/helpers/subscriptions.js | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/renderer/helpers/subscriptions.js b/src/renderer/helpers/subscriptions.js index 143c38f6cd7f8..c99b0b843afd5 100644 --- a/src/renderer/helpers/subscriptions.js +++ b/src/renderer/helpers/subscriptions.js @@ -8,20 +8,6 @@ import { calculatePublishedDate } from './utils' export function updateVideoListAfterProcessing(videos) { let videoList = videos - if (store.getters.getOnlyShowLatestFromChannel) { - const authors = new Set() - videoList = videoList.filter((video) => { - if (!video.authorId) { - return true - } else if (!authors.has(video.authorId)) { - authors.add(video.authorId) - return true - } - - return false - }) - } - if (store.getters.getHideLiveStreams) { videoList = videoList.filter(item => { return (!item.liveNow && !item.isUpcoming) @@ -54,6 +40,22 @@ export function updateVideoListAfterProcessing(videos) { }) } + // ordered last to show first eligible video from channel + // if the first one incidentally failed one of the above checks + if (store.getters.getOnlyShowLatestFromChannel) { + const authors = new Set() + videoList = videoList.filter((video) => { + if (!video.authorId) { + return true + } else if (!authors.has(video.authorId)) { + authors.add(video.authorId) + return true + } + + return false + }) + } + videoList.sort((a, b) => { return b.publishedDate - a.publishedDate })