Show latest from channel (#4352)

* Implement 'show latest video from channel' feature

* Apply suggestions from code review

Co-authored-by: PikachuEXE <pikachuexe@gmail.com>

* Adjust ordering to maximize chance of content being presented

---------

Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
This commit is contained in:
Jason 2023-11-26 00:27:29 +00:00 committed by GitHub
parent e05827b482
commit 6af85b3726
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 6 deletions

View File

@ -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'
])
}
})

View File

@ -26,6 +26,12 @@
:compact="true"
@change="updateHideWatchedSubs"
/>
<ft-toggle-switch
:label="$t('Settings.Subscription Settings.Only Show Latest Video for Each Channel')"
:default-value="onlyShowLatestFromChannel"
:compact="true"
@change="updateOnlyShowLatestFromChannel"
/>
</div>
</div>
</ft-settings-section>

View File

@ -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
}

View File

@ -230,6 +230,7 @@ const state = {
landingPage: 'subscriptions',
listType: 'grid',
maxVideoPlaybackRate: 3,
onlyShowLatestFromChannel: false,
playNextVideo: false,
proxyHostname: '127.0.0.1',
proxyPort: '9050',

View File

@ -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: