mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Merge pull request #3411 from justcallmelarry/feature/add-duration-when-creating-sessions
Add duration to local sessions on creation
This commit is contained in:
		
						commit
						3d9af89e24
					
				| @ -164,6 +164,7 @@ class PlaybackSessionManager { | ||||
|       // New session from local
 | ||||
|       session = new PlaybackSession(sessionJson) | ||||
|       session.deviceInfo = deviceInfo | ||||
|       session.setDuration(libraryItem, sessionJson.episodeId) | ||||
|       Logger.debug(`[PlaybackSessionManager] Inserting new session for "${session.displayTitle}" (${session.id})`) | ||||
|       await Database.createPlaybackSession(session) | ||||
|     } else { | ||||
|  | ||||
| @ -219,11 +219,7 @@ class PlaybackSession { | ||||
|     this.displayAuthor = libraryItem.media.getPlaybackAuthor() | ||||
|     this.coverPath = libraryItem.media.coverPath | ||||
| 
 | ||||
|     if (episodeId) { | ||||
|       this.duration = libraryItem.media.getEpisodeDuration(episodeId) | ||||
|     } else { | ||||
|       this.duration = libraryItem.media.duration | ||||
|     } | ||||
|     this.setDuration(libraryItem, episodeId) | ||||
| 
 | ||||
|     this.mediaPlayer = mediaPlayer | ||||
|     this.deviceInfo = deviceInfo || new DeviceInfo() | ||||
| @ -239,6 +235,14 @@ class PlaybackSession { | ||||
|     this.updatedAt = Date.now() | ||||
|   } | ||||
| 
 | ||||
|   setDuration(libraryItem, episodeId) { | ||||
|     if (episodeId) { | ||||
|       this.duration = libraryItem.media.getEpisodeDuration(episodeId) | ||||
|     } else { | ||||
|       this.duration = libraryItem.media.duration | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   addListeningTime(timeListened) { | ||||
|     if (!timeListened || isNaN(timeListened)) return | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user