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

Order watched recommended videos last #4394

Merged
Merged
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
19 changes: 17 additions & 2 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,16 @@ export default defineComponent({

this.isFamilyFriendly = result.basic_info.is_family_safe

this.recommendedVideos = result.watch_next_feed
const recommendedVideos = result.watch_next_feed
?.filter((item) => item.type === 'CompactVideo')
.map(parseLocalWatchNextVideo) ?? []

// place watched recommended videos last
this.recommendedVideos = [
...recommendedVideos.filter((video) => !this.isRecommendedVideoWatched(video.videoId)),
...recommendedVideos.filter((video) => this.isRecommendedVideoWatched(video.videoId))
]

if (this.showFamilyFriendlyOnly && !this.isFamilyFriendly) {
this.isLoading = false
this.handleVideoEnded()
Expand Down Expand Up @@ -699,7 +705,12 @@ export default defineComponent({

this.videoPublished = result.published * 1000
this.videoDescriptionHtml = result.descriptionHtml
this.recommendedVideos = result.recommendedVideos
const recommendedVideos = result.recommendedVideos
// place watched recommended videos last
this.recommendedVideos = [
...recommendedVideos.filter((video) => !this.isRecommendedVideoWatched(video.videoId)),
...recommendedVideos.filter((video) => this.isRecommendedVideoWatched(video.videoId))
]
this.adaptiveFormats = await this.getAdaptiveFormatsInvidious(result)
this.isLive = result.liveNow
this.isFamilyFriendly = result.isFamilyFriendly
Expand Down Expand Up @@ -1067,6 +1078,10 @@ export default defineComponent({
this.checkIfWatched()
},

isRecommendedVideoWatched: function (videoId) {
return !!this.$store.getters.getHistoryCacheById[videoId]
},

checkIfWatched: function () {
if (!this.isLive) {
if (this.timestamp) {
Expand Down