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"
>