Update episode list to come from component ref, populate queue from table order when playing episode

This commit is contained in:
advplyr 2025-02-25 17:25:56 -06:00
parent 72169990ac
commit fd1c8ee513
3 changed files with 11 additions and 28 deletions

View file

@ -89,13 +89,6 @@ export default {
handler() {
this.refresh()
}
},
episodesList: {
handler(newList) {
const episodeIds = newList.map((ep) => ep.id)
this.$store.commit('setSortedEpisodeIds', episodeIds)
},
immediate: true
}
},
computed: {
@ -368,20 +361,20 @@ export default {
playEpisode(episode) {
const queueItems = []
const episodesInListeningOrder = this.episodesCopy.map((ep) => ({ ...ep })).sort((a, b) => String(a.publishedAt).localeCompare(String(b.publishedAt), undefined, { numeric: true, sensitivity: 'base' }))
const episodesInListeningOrder = this.episodesList
const episodeIndex = episodesInListeningOrder.findIndex((e) => e.id === episode.id)
for (let i = episodeIndex; i < episodesInListeningOrder.length; i++) {
const episode = episodesInListeningOrder[i]
const podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, episode.id)
if (!podcastProgress || !podcastProgress.isFinished) {
const _episode = episodesInListeningOrder[i]
const podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItem.id, _episode.id)
if (!podcastProgress?.isFinished || episode.id === _episode.id) {
queueItems.push({
libraryItemId: this.libraryItem.id,
libraryId: this.libraryItem.libraryId,
episodeId: episode.id,
title: episode.title,
episodeId: _episode.id,
title: _episode.title,
subtitle: this.mediaMetadata.title,
caption: episode.publishedAt ? this.$getString('LabelPublishedDate', [this.$formatDate(episode.publishedAt, this.dateFormat)]) : this.$strings.LabelUnknownPublishDate,
duration: episode.audioFile.duration || null,
caption: _episode.publishedAt ? this.$getString('LabelPublishedDate', [this.$formatDate(_episode.publishedAt, this.dateFormat)]) : this.$strings.LabelUnknownPublishDate,
duration: _episode.audioFile.duration || null,
coverPath: this.media.coverPath || null
})
}