Watch: stop autoplay countdown toasts when navigating to another page (#1287)

This commit is contained in:
PikachuEXE 2021-06-15 02:10:21 +08:00 committed by GitHub
parent bb3edb750f
commit ce15f4b7c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -74,7 +74,8 @@ export default Vue.extend({
watchingPlaylist: false, watchingPlaylist: false,
playlistId: '', playlistId: '',
timestamp: null, timestamp: null,
playNextTimeout: null playNextTimeout: null,
playNextCountDownIntervalId: null
} }
}, },
computed: { computed: {
@ -900,7 +901,7 @@ export default Vue.extend({
// Will not display "Playing next video in no time" as it's too late to cancel // Will not display "Playing next video in no time" as it's too late to cancel
// Also there is a separate message when playing next video // Also there is a separate message when playing next video
if (countDownTimeLeftInSecond <= 0) { if (countDownTimeLeftInSecond <= 0) {
clearInterval(countDownIntervalId) clearInterval(this.playNextCountDownIntervalId)
return return
} }
@ -911,7 +912,7 @@ export default Vue.extend({
time: 700, time: 700,
action: () => { action: () => {
clearTimeout(this.playNextTimeout) clearTimeout(this.playNextTimeout)
clearInterval(countDownIntervalId) clearInterval(this.playNextCountDownIntervalId)
this.showToast({ this.showToast({
message: this.$t('Canceled next video autoplay') message: this.$t('Canceled next video autoplay')
}) })
@ -923,11 +924,12 @@ export default Vue.extend({
} }
// Execute once before scheduling it // Execute once before scheduling it
showCountDownMessage() showCountDownMessage()
const countDownIntervalId = setInterval(showCountDownMessage, 1000) this.playNextCountDownIntervalId = setInterval(showCountDownMessage, 1000)
}, },
handleRouteChange: async function () { handleRouteChange: async function () {
clearTimeout(this.playNextTimeout) clearTimeout(this.playNextTimeout)
clearInterval(this.playNextCountDownIntervalId)
this.handleWatchProgress() this.handleWatchProgress()