From 6af85b3726edba74ed31a234f01460b31e596c2b Mon Sep 17 00:00:00 2001 From: Jason <84899178+jasonhenriquez@users.noreply.github.com> Date: Sun, 26 Nov 2023 00:27:29 +0000 Subject: [PATCH] Show latest from channel (#4352) * Implement 'show latest video from channel' feature * Apply suggestions from code review Co-authored-by: PikachuEXE * Adjust ordering to maximize chance of content being presented --------- Co-authored-by: PikachuEXE --- .../subscription-settings.js | 6 ++++- .../subscription-settings.vue | 6 +++++ src/renderer/helpers/subscriptions.js | 25 +++++++++++++++---- src/renderer/store/modules/settings.js | 1 + static/locales/en-US.yaml | 1 + 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/renderer/components/subscription-settings/subscription-settings.js b/src/renderer/components/subscription-settings/subscription-settings.js index 303a5d20c..19404a4d6 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 ad6269f8a..090e39c87 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 8ee8d78d8..c99b0b843 100644 --- a/src/renderer/helpers/subscriptions.js +++ b/src/renderer/helpers/subscriptions.js @@ -8,11 +8,6 @@ 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.getHideLiveStreams) { videoList = videoList.filter(item => { return (!item.liveNow && !item.isUpcoming) @@ -45,6 +40,26 @@ 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 + }) + return videoList } diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 037d446fe..4052e4351 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -230,6 +230,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 301f53b5d..1fbe3e902 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -339,6 +339,7 @@ Settings: Fetch Feeds from RSS: Fetch Feeds from RSS Manage Subscriptions: Manage Subscriptions Fetch Automatically: Fetch Feed Automatically + Only Show Latest Video for Each Channel: Only Show Latest Video for Each Channel Distraction Free Settings: Distraction Free Settings: Distraction Free Settings Sections: