mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-03 09:44:41 +02:00
Fix:Close open playback session on server when local playback session syncing from mobile
This commit is contained in:
parent
702ee3d350
commit
6dec750d3e
3 changed files with 21 additions and 8 deletions
|
@ -73,6 +73,17 @@ class PlaybackSessionManager {
|
|||
return res.status(500).send('Library item not found')
|
||||
}
|
||||
|
||||
// If server session is open for this same media item then close it
|
||||
const userSessionForThisItem = this.sessions.find(playbackSession => {
|
||||
if (playbackSession.userId !== user.id) return false
|
||||
if (sessionJson.episodeId) return playbackSession.episodeId !== sessionJson.episodeId
|
||||
return playbackSession.libraryItemId === sessionJson.libraryItemId
|
||||
})
|
||||
if (userSessionForThisItem) {
|
||||
Logger.info(`[PlaybackSessionManager] syncLocalSessionRequest: Closing open session "${userSessionForThisItem.displayTitle}" for user "${user.username}"`)
|
||||
await this.closeSession(user, userSessionForThisItem, null)
|
||||
}
|
||||
|
||||
this.localSessionLock[sessionJson.id] = true // Lock local session
|
||||
|
||||
let session = await this.db.getPlaybackSession(sessionJson.id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue