mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-11-04 03:17:00 -05:00 
			
		
		
		
	Fix chapter end sleep timer sometimes not stopping #3969
This commit is contained in:
		
							parent
							
								
									5ca12eee19
								
							
						
					
					
						commit
						c4d99a118f
					
				@ -85,7 +85,8 @@ export default {
 | 
				
			|||||||
      displayTitle: null,
 | 
					      displayTitle: null,
 | 
				
			||||||
      currentPlaybackRate: 1,
 | 
					      currentPlaybackRate: 1,
 | 
				
			||||||
      syncFailedToast: null,
 | 
					      syncFailedToast: null,
 | 
				
			||||||
      coverAspectRatio: 1
 | 
					      coverAspectRatio: 1,
 | 
				
			||||||
 | 
					      lastChapterId: null
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  computed: {
 | 
					  computed: {
 | 
				
			||||||
@ -236,13 +237,17 @@ export default {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
      }, 1000)
 | 
					      }, 1000)
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    checkChapterEnd(time) {
 | 
					    checkChapterEnd() {
 | 
				
			||||||
      if (!this.currentChapter) return
 | 
					      if (!this.currentChapter) return
 | 
				
			||||||
      const chapterEndTime = this.currentChapter.end
 | 
					
 | 
				
			||||||
      const tolerance = 0.75
 | 
					      // Track chapter transitions by comparing current chapter with last chapter
 | 
				
			||||||
      if (time >= chapterEndTime - tolerance) {
 | 
					      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.sleepTimerEnd()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        this.lastChapterId = this.currentChapter.id
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    sleepTimerEnd() {
 | 
					    sleepTimerEnd() {
 | 
				
			||||||
      this.clearSleepTimer()
 | 
					      this.clearSleepTimer()
 | 
				
			||||||
@ -301,7 +306,7 @@ export default {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (this.sleepTimerType === this.$constants.SleepTimerTypes.CHAPTER && this.sleepTimerSet) {
 | 
					      if (this.sleepTimerType === this.$constants.SleepTimerTypes.CHAPTER && this.sleepTimerSet) {
 | 
				
			||||||
        this.checkChapterEnd(time)
 | 
					        this.checkChapterEnd()
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    setDuration(duration) {
 | 
					    setDuration(duration) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user