diff --git a/client/components/tables/podcast/LazyEpisodesTable.vue b/client/components/tables/podcast/LazyEpisodesTable.vue index 8821ccef..af0f5584 100644 --- a/client/components/tables/podcast/LazyEpisodesTable.vue +++ b/client/components/tables/podcast/LazyEpisodesTable.vue @@ -361,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 }) } diff --git a/client/pages/item/_id/index.vue b/client/pages/item/_id/index.vue index 5555250b..012d9e08 100644 --- a/client/pages/item/_id/index.vue +++ b/client/pages/item/_id/index.vue @@ -132,7 +132,7 @@ - + @@ -534,13 +534,15 @@ export default { let episodeId = null const queueItems = [] if (this.isPodcast) { - const episodesInListeningOrder = this.podcastEpisodes.map((ep) => ({ ...ep })).sort((a, b) => String(a.publishedAt).localeCompare(String(b.publishedAt), undefined, { numeric: true, sensitivity: 'base' })) + // Uses the sorting and filtering from the episode table component + const episodesInListeningOrder = this.$refs.episodesTable?.episodesList || [] - // Find most recent episode unplayed - let episodeIndex = episodesInListeningOrder.findLastIndex((ep) => { + // Find the first unplayed episode from the table + let episodeIndex = episodesInListeningOrder.findIndex((ep) => { const podcastProgress = this.$store.getters['user/getUserMediaProgress'](this.libraryItemId, ep.id) return !podcastProgress || !podcastProgress.isFinished }) + // If all episodes are played, use the first episode if (episodeIndex < 0) episodeIndex = 0 episodeId = episodesInListeningOrder[episodeIndex].id