diff --git a/src/renderer/components/player-settings/player-settings.js b/src/renderer/components/player-settings/player-settings.js index ef2fc22df36f9..54611a59f16f1 100644 --- a/src/renderer/components/player-settings/player-settings.js +++ b/src/renderer/components/player-settings/player-settings.js @@ -57,7 +57,7 @@ export default defineComponent({ ], screenshotFolderPlaceholder: '', screenshotFilenameExample: '', - screenshotDefaultPattern: '%Y%M%D-%H%N%S' + screenshotDefaultPattern: '%Y%M%D-%H%N%S', } }, computed: { @@ -195,11 +195,24 @@ export default defineComponent({ screenshotFilenamePattern: function() { return this.$store.getters.getScreenshotFilenamePattern - } + }, + + commentAutoLoadEnabled: function () { + return this.$store.getters.getCommentAutoLoadEnabled + }, + + hideComments: function () { + return this.$store.getters.getHideComments + }, }, watch: { screenshotFolder: function() { this.getScreenshotFolderPlaceholder() + }, + hideComments: function(newValue) { + if (newValue) { + this.updateCommentAutoLoadEnabled(false) + } } }, mounted: function() { @@ -295,6 +308,7 @@ export default defineComponent({ 'updateScreenshotFolderPath', 'updateScreenshotFilenamePattern', 'parseScreenshotCustomFileName', + 'updateCommentAutoLoadEnabled', ]) } }) diff --git a/src/renderer/components/player-settings/player-settings.vue b/src/renderer/components/player-settings/player-settings.vue index fbac7098d8aea..11e40690d5fd5 100644 --- a/src/renderer/components/player-settings/player-settings.vue +++ b/src/renderer/components/player-settings/player-settings.vue @@ -249,7 +249,16 @@ :disabled="true" /> +
+ + + diff --git a/src/renderer/components/watch-video-comments/watch-video-comments.js b/src/renderer/components/watch-video-comments/watch-video-comments.js index 219aa7a64f4d2..82b8b944517fe 100644 --- a/src/renderer/components/watch-video-comments/watch-video-comments.js +++ b/src/renderer/components/watch-video-comments/watch-video-comments.js @@ -27,7 +27,11 @@ export default defineComponent({ channelThumbnail: { type: String, required: true - } + }, + videoPlayerReady: { + type: Boolean, + required: true + }, }, data: function () { return { @@ -35,7 +39,7 @@ export default defineComponent({ showComments: false, nextPageToken: null, commentData: [], - sortNewest: false + sortNewest: false, } }, computed: { @@ -54,6 +58,10 @@ export default defineComponent({ return this.$store.getters.getHideCommentLikes }, + commentAutoLoadEnabled: function () { + return this.$store.getters.getCommentAutoLoadEnabled + }, + sortNames: function () { return [ this.$t('Comments.Top comments'), @@ -70,7 +78,40 @@ export default defineComponent({ currentSortValue: function () { return (this.sortNewest) ? 'newest' : 'top' - } + }, + + observeVisibilityOptions: function() { + if (!this.commentAutoLoadEnabled) { return false } + if (!this.videoPlayerReady) { return false } + + return { + callback: (isVisible, _entry) => { + // This is also fired when **hidden** + // No point doing anything if not visible + if (!isVisible) { return } + // It's possible the comments are being loaded/already loaded + if (this.canPerformInitialCommentLoading) { + this.getCommentData() + } else if (this.canPerformMoreCommentLoading) { + this.getMoreComments() + } + }, + intersection: { + // Only when it intersects with N% above bottom + rootMargin: '0% 0% 0% 0%', + }, + // Callback responsible for loading multiple comment pages + once: false, + } + }, + + canPerformInitialCommentLoading: function() { + return this.commentData.length === 0 && !this.isLoading && !this.showComments + }, + + canPerformMoreCommentLoading: function() { + return this.commentData.length > 0 && !this.isLoading && this.showComments && this.nextPageToken + }, }, methods: { @@ -242,6 +283,6 @@ export default defineComponent({ }) this.isLoading = false }) - } + }, } }) diff --git a/src/renderer/components/watch-video-comments/watch-video-comments.vue b/src/renderer/components/watch-video-comments/watch-video-comments.vue index e8ee3de2c1338..c718683d58377 100644 --- a/src/renderer/components/watch-video-comments/watch-video-comments.vue +++ b/src/renderer/components/watch-video-comments/watch-video-comments.vue @@ -3,7 +3,7 @@ class="card" >

+
+ +
diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 8c02127232e6c..c828978b72c78 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -281,6 +281,7 @@ const state = { fetchSubscriptionsAutomatically: true, settingsPassword: '', allowDashAv1Formats: false, + commentAutoLoadEnabled: false, } const stateWithSideEffects = { diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index 58826995f2b36..fac1e96963103 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -55,6 +55,7 @@ export default defineComponent({ isLoading: true, firstLoad: true, useTheatreMode: false, + videoPlayerReady: false, showDashPlayer: true, showLegacyPlayer: false, showYouTubeNoCookieEmbed: false, @@ -98,7 +99,7 @@ export default defineComponent({ timestamp: null, playNextTimeout: null, playNextCountDownIntervalId: null, - infoAreaSticky: true + infoAreaSticky: true, } }, computed: { @@ -182,7 +183,7 @@ export default defineComponent({ }, allowDashAv1Formats: function () { return this.$store.getters.getAllowDashAv1Formats - } + }, }, watch: { $route() { @@ -191,6 +192,7 @@ export default defineComponent({ this.videoId = this.$route.params.id this.firstLoad = true + this.videoPlayerReady = false this.activeFormat = this.defaultVideoFormat this.videoStoryboardSrc = '' this.captionHybridList = [] @@ -928,6 +930,11 @@ export default defineComponent({ this.updateLastViewedPlaylist(payload) }, + handleVideoReady: function () { + this.videoPlayerReady = true + this.checkIfWatched() + }, + checkIfWatched: function () { const historyIndex = this.historyCache.findIndex((video) => { return video.videoId === this.videoId diff --git a/src/renderer/views/Watch/Watch.vue b/src/renderer/views/Watch/Watch.vue index 354fd535fb91b..97a85a5083737 100644 --- a/src/renderer/views/Watch/Watch.vue +++ b/src/renderer/views/Watch/Watch.vue @@ -31,7 +31,7 @@ :chapters="videoChapters" class="videoPlayer" :class="{ theatrePlayer: useTheatreMode }" - @ready="checkIfWatched" + @ready="handleVideoReady" @ended="handleVideoEnded" @error="handleVideoError" @store-caption-list="captionHybridList = $event" @@ -144,6 +144,7 @@ :class="{ theatreWatchVideo: useTheatreMode }" :channel-thumbnail="channelThumbnail" :channel-name="channelName" + :video-player-ready="videoPlayerReady" @timestamp-event="changeTimestamp" /> diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index 76f3c5b96d011..9622464ad2425 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -280,6 +280,8 @@ Settings: Error: Forbidden Characters: Forbidden Characters Empty File Name: Empty File Name + Comment Auto Load: + Comment Auto Load: Comment Auto Load External Player Settings: External Player Settings: External Player Settings External Player: External Player