Update media progress object to use unique id for podcast episodes

This commit is contained in:
advplyr 2022-04-08 19:19:47 -05:00
parent 3276b04256
commit 3a7cafbb95
2 changed files with 4 additions and 4 deletions

View File

@ -53,7 +53,7 @@ class MediaProgress {
} }
setData(libraryItemId, progress, episodeId = null) { setData(libraryItemId, progress, episodeId = null) {
this.id = libraryItemId this.id = episodeId ? `${libraryItemId}-${episodeId}` : libraryItemId
this.libraryItemId = libraryItemId this.libraryItemId = libraryItemId
this.episodeId = episodeId this.episodeId = episodeId
this.duration = progress.duration || 0 this.duration = progress.duration || 0

View File

@ -247,14 +247,14 @@ class User {
if (!this.mediaProgress) return null if (!this.mediaProgress) return null
return this.mediaProgress.find(lip => { return this.mediaProgress.find(lip => {
if (episodeId && lip.episodeId !== episodeId) return false if (episodeId && lip.episodeId !== episodeId) return false
return lip.id === libraryItemId return lip.libraryItemId === libraryItemId
}) })
} }
createUpdateMediaProgress(libraryItem, updatePayload, episodeId = null) { createUpdateMediaProgress(libraryItem, updatePayload, episodeId = null) {
var itemProgress = this.mediaProgress.find(li => { var itemProgress = this.mediaProgress.find(li => {
if (episodeId && li.episodeId !== episodeId) return false if (episodeId && li.episodeId !== episodeId) return false
return li.id === libraryItem.id return li.libraryItemId === libraryItem.id
}) })
if (!itemProgress) { if (!itemProgress) {
var newItemProgress = new MediaProgress() var newItemProgress = new MediaProgress()
@ -269,7 +269,7 @@ class User {
removeMediaProgress(libraryItemId) { removeMediaProgress(libraryItemId) {
if (!this.mediaProgress.some(lip => lip.id == libraryItemId)) return false if (!this.mediaProgress.some(lip => lip.id == libraryItemId)) return false
this.mediaProgress = this.mediaProgress.filter(lip => lip.id != libraryItemId) this.mediaProgress = this.mediaProgress.filter(lip => lip.libraryItemId != libraryItemId)
return true return true
} }