From c4d99a118fc0ebd613bf58dd73324a4776e942f8 Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 14 Feb 2025 16:24:39 -0600 Subject: [PATCH] Fix chapter end sleep timer sometimes not stopping #3969 --- .../components/app/MediaPlayerContainer.vue | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/client/components/app/MediaPlayerContainer.vue b/client/components/app/MediaPlayerContainer.vue index cf22d322..8aa6188b 100644 --- a/client/components/app/MediaPlayerContainer.vue +++ b/client/components/app/MediaPlayerContainer.vue @@ -85,7 +85,8 @@ export default { displayTitle: null, currentPlaybackRate: 1, syncFailedToast: null, - coverAspectRatio: 1 + coverAspectRatio: 1, + lastChapterId: null } }, computed: { @@ -236,12 +237,16 @@ export default { } }, 1000) }, - checkChapterEnd(time) { + checkChapterEnd() { if (!this.currentChapter) return - const chapterEndTime = this.currentChapter.end - const tolerance = 0.75 - if (time >= chapterEndTime - tolerance) { - this.sleepTimerEnd() + + // Track chapter transitions by comparing current chapter with last chapter + if (this.lastChapterId !== this.currentChapter.id) { + // Chapter changed - if we had a previous chapter, this means we crossed a boundary + if (this.lastChapterId) { + this.sleepTimerEnd() + } + this.lastChapterId = this.currentChapter.id } }, sleepTimerEnd() { @@ -301,7 +306,7 @@ export default { } if (this.sleepTimerType === this.$constants.SleepTimerTypes.CHAPTER && this.sleepTimerSet) { - this.checkChapterEnd(time) + this.checkChapterEnd() } }, setDuration(duration) {