From f010dcf6c66483fc9e6c933ac317a9da604437f7 Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Sat, 25 Nov 2023 20:39:48 -0600 Subject: [PATCH 1/2] Implement change --- src/renderer/views/Watch/Watch.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index 7a8412793d1a6..d3c3b78063a5f 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -281,6 +281,12 @@ export default defineComponent({ ?.filter((item) => item.type === 'CompactVideo') .map(parseLocalWatchNextVideo) ?? [] + // place watched recommended videos last + this.recommendedVideos = [ + ...this.recommendedVideos.filter((video) => !this.isRecommendedVideoWatched(video.videoId)), + ...this.recommendedVideos.filter((video) => this.isRecommendedVideoWatched(video.videoId)) + ] + if (this.showFamilyFriendlyOnly && !this.isFamilyFriendly) { this.isLoading = false this.handleVideoEnded() @@ -700,6 +706,11 @@ export default defineComponent({ this.videoPublished = result.published * 1000 this.videoDescriptionHtml = result.descriptionHtml this.recommendedVideos = result.recommendedVideos + // place watched recommended videos last + this.recommendedVideos = [ + ...this.recommendedVideos.filter((video) => !this.isRecommendedVideoWatched(video.videoId)), + ...this.recommendedVideos.filter((video) => this.isRecommendedVideoWatched(video.videoId)) + ] this.adaptiveFormats = await this.getAdaptiveFormatsInvidious(result) this.isLive = result.liveNow this.isFamilyFriendly = result.isFamilyFriendly @@ -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) { From 0ebb220149516d000dde59a97c5e775bd3d36f6b Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Fri, 1 Dec 2023 07:17:37 -0600 Subject: [PATCH 2/2] Update to use local variable to potentially improve performance in non-first load case --- src/renderer/views/Watch/Watch.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index d3c3b78063a5f..71d3dfe9c6c50 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -277,14 +277,14 @@ 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 = [ - ...this.recommendedVideos.filter((video) => !this.isRecommendedVideoWatched(video.videoId)), - ...this.recommendedVideos.filter((video) => this.isRecommendedVideoWatched(video.videoId)) + ...recommendedVideos.filter((video) => !this.isRecommendedVideoWatched(video.videoId)), + ...recommendedVideos.filter((video) => this.isRecommendedVideoWatched(video.videoId)) ] if (this.showFamilyFriendlyOnly && !this.isFamilyFriendly) { @@ -705,11 +705,11 @@ 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 = [ - ...this.recommendedVideos.filter((video) => !this.isRecommendedVideoWatched(video.videoId)), - ...this.recommendedVideos.filter((video) => this.isRecommendedVideoWatched(video.videoId)) + ...recommendedVideos.filter((video) => !this.isRecommendedVideoWatched(video.videoId)), + ...recommendedVideos.filter((video) => this.isRecommendedVideoWatched(video.videoId)) ] this.adaptiveFormats = await this.getAdaptiveFormatsInvidious(result) this.isLive = result.liveNow