mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Update:Increase timeout for progress sync to 6s and sync interval to 10s #1884
This commit is contained in:
		
							parent
							
								
									bdbc5e3161
								
							
						
					
					
						commit
						8140d7021a
					
				@ -281,6 +281,10 @@ export default class PlayerHandler {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * First sync happens after 20 seconds
 | 
			
		||||
   * subsequent syncs happen every 10 seconds
 | 
			
		||||
   */
 | 
			
		||||
  startPlayInterval() {
 | 
			
		||||
    clearInterval(this.playInterval)
 | 
			
		||||
    let lastTick = Date.now()
 | 
			
		||||
@ -293,7 +297,7 @@ export default class PlayerHandler {
 | 
			
		||||
      const exactTimeElapsed = ((Date.now() - lastTick) / 1000)
 | 
			
		||||
      lastTick = Date.now()
 | 
			
		||||
      this.listeningTimeSinceSync += exactTimeElapsed
 | 
			
		||||
      const TimeToWaitBeforeSync = this.lastSyncTime > 0 ? 5 : 20
 | 
			
		||||
      const TimeToWaitBeforeSync = this.lastSyncTime > 0 ? 10 : 20
 | 
			
		||||
      if (this.listeningTimeSinceSync >= TimeToWaitBeforeSync) {
 | 
			
		||||
        this.sendProgressSync(currentTime)
 | 
			
		||||
      }
 | 
			
		||||
@ -315,7 +319,7 @@ export default class PlayerHandler {
 | 
			
		||||
    }
 | 
			
		||||
    this.listeningTimeSinceSync = 0
 | 
			
		||||
    this.lastSyncTime = 0
 | 
			
		||||
    return this.ctx.$axios.$post(`/api/session/${this.currentSessionId}/close`, syncData, { timeout: 1000 }).catch((error) => {
 | 
			
		||||
    return this.ctx.$axios.$post(`/api/session/${this.currentSessionId}/close`, syncData, { timeout: 4000 }).catch((error) => {
 | 
			
		||||
      console.error('Failed to close session', error)
 | 
			
		||||
    })
 | 
			
		||||
  }
 | 
			
		||||
@ -335,7 +339,7 @@ export default class PlayerHandler {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.listeningTimeSinceSync = 0
 | 
			
		||||
    this.ctx.$axios.$post(`/api/session/${this.currentSessionId}/sync`, syncData, { timeout: 3000 }).then(() => {
 | 
			
		||||
    this.ctx.$axios.$post(`/api/session/${this.currentSessionId}/sync`, syncData, { timeout: 6000 }).then(() => {
 | 
			
		||||
      this.failedProgressSyncs = 0
 | 
			
		||||
    }).catch((error) => {
 | 
			
		||||
      console.error('Failed to update session progress', error)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user