Skip to content

Commit

Permalink
* Remove the unnecessary delay on video comment loading
Browse files Browse the repository at this point in the history
  • Loading branch information
PikachuEXE committed Apr 8, 2023
1 parent 56dec89 commit 31d16a0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export default defineComponent({
channelThumbnail: {
type: String,
required: true
}
},
videoPlayerReady: {
type: Boolean,
required: true
},
},
data: function () {
return {
Expand Down Expand Up @@ -78,6 +82,7 @@ export default defineComponent({

observeVisibilityOptions: function() {
if (!this.commentAutoLoadEnabled) { return false }
if (!this.videoPlayerReady) { return false }

return {
callback: (isVisible, _entry) => {
Expand All @@ -96,9 +101,6 @@ export default defineComponent({
// Only when it intersects with N% above bottom
rootMargin: '0% 0% 0% 0%',
},
// The video player is minimized on startup for < about 1s
// `throttle` is needed to prevent unwanted autoload during that period
throttle: 1000,
// Callback responsible for loading multiple comment pages
once: false,
}
Expand Down
10 changes: 8 additions & 2 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default defineComponent({
isLoading: true,
firstLoad: true,
useTheatreMode: false,
videoPlayerReady: false,
showDashPlayer: true,
showLegacyPlayer: false,
showYouTubeNoCookieEmbed: false,
Expand Down Expand Up @@ -98,7 +99,7 @@ export default defineComponent({
timestamp: null,
playNextTimeout: null,
playNextCountDownIntervalId: null,
infoAreaSticky: true
infoAreaSticky: true,
}
},
computed: {
Expand Down Expand Up @@ -182,7 +183,7 @@ export default defineComponent({
},
allowDashAv1Formats: function () {
return this.$store.getters.getAllowDashAv1Formats
}
},
},
watch: {
$route() {
Expand Down Expand Up @@ -928,6 +929,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
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/views/Watch/Watch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
:chapters="videoChapters"
class="videoPlayer"
:class="{ theatrePlayer: useTheatreMode }"
@ready="checkIfWatched"
@ready="handleVideoReady"
@ended="handleVideoEnded"
@error="handleVideoError"
@store-caption-list="captionHybridList = $event"
Expand Down Expand Up @@ -144,6 +144,7 @@
:class="{ theatreWatchVideo: useTheatreMode }"
:channel-thumbnail="channelThumbnail"
:channel-name="channelName"
:video-player-ready="videoPlayerReady"
@timestamp-event="changeTimestamp"
/>
</div>
Expand Down

0 comments on commit 31d16a0

Please sign in to comment.