diff --git a/client/components/modals/podcast/EpisodeFeed.vue b/client/components/modals/podcast/EpisodeFeed.vue index 5092d8b1..9c199325 100644 --- a/client/components/modals/podcast/EpisodeFeed.vue +++ b/client/components/modals/podcast/EpisodeFeed.vue @@ -6,7 +6,7 @@
-
+
@@ -16,12 +16,12 @@ v-for="(episode, index) in episodesList" :key="index" class="relative" - :class="itemEpisodeMap[episode.enclosure.url?.split('?')[0]] ? 'bg-primary bg-opacity-40' : selectedEpisodes[String(index)] ? 'cursor-pointer bg-success bg-opacity-10' : index % 2 == 0 ? 'cursor-pointer bg-primary bg-opacity-25 hover:bg-opacity-40' : 'cursor-pointer bg-primary bg-opacity-5 hover:bg-opacity-25'" - @click="toggleSelectEpisode(index, episode)" + :class="itemEpisodeMap[episode.cleanUrl] ? 'bg-primary bg-opacity-40' : selectedEpisodes[episode.cleanUrl] ? 'cursor-pointer bg-success bg-opacity-10' : index % 2 == 0 ? 'cursor-pointer bg-primary bg-opacity-25 hover:bg-opacity-40' : 'cursor-pointer bg-primary bg-opacity-5 hover:bg-opacity-25'" + @click="toggleSelectEpisode(episode)" >
- download_done - + download_done +
@@ -63,6 +63,7 @@ export default { data() { return { processing: false, + episodesCleaned: [], selectedEpisodes: {}, selectAll: false, search: null, @@ -92,7 +93,7 @@ export default { return this.libraryItem.media.metadata.title || 'Unknown' }, allDownloaded() { - return !this.episodes.some((episode) => !this.itemEpisodeMap[episode.enclosure.url?.split('?')[0]]) + return !this.episodesCleaned.some((episode) => !this.itemEpisodeMap[episode.cleanUrl]) }, episodesSelected() { return Object.keys(this.selectedEpisodes).filter((key) => !!this.selectedEpisodes[key]) @@ -113,7 +114,7 @@ export default { return map }, episodesList() { - return this.episodes.filter((episode) => { + return this.episodesCleaned.filter((episode) => { if (!this.searchText) return true return (episode.title && episode.title.toLowerCase().includes(this.searchText)) || (episode.subtitle && episode.subtitle.toLowerCase().includes(this.searchText)) }) @@ -131,31 +132,29 @@ export default { }, 500) }, toggleSelectAll(val) { - for (let i = 0; i < this.episodes.length; i++) { - const episode = this.episodes[i] - if (this.itemEpisodeMap[episode.enclosure.url?.split('?')[0]]) this.selectedEpisodes[String(i)] = false - else this.$set(this.selectedEpisodes, String(i), val) + for (const episode of this.episodesCleaned) { + if (this.itemEpisodeMap[episode.cleanUrl]) this.selectedEpisodes[episode.cleanUrl] = false + else this.$set(this.selectedEpisodes, episode.cleanUrl, val) } }, checkSetIsSelectedAll() { - for (let i = 0; i < this.episodes.length; i++) { - const episode = this.episodes[i] - if (!this.itemEpisodeMap[episode.enclosure.url?.split('?')[0]] && !this.selectedEpisodes[String(i)]) { + for (const episode of this.episodesCleaned) { + if (!this.itemEpisodeMap[episode.cleanUrl] && !this.selectedEpisodes[episode.cleanUrl]) { this.selectAll = false return } } this.selectAll = true }, - toggleSelectEpisode(index, episode) { + toggleSelectEpisode(episode) { if (this.itemEpisodeMap[episode.enclosure.url?.split('?')[0]]) return - this.$set(this.selectedEpisodes, String(index), !this.selectedEpisodes[String(index)]) + this.$set(this.selectedEpisodes, episode.cleanUrl, !this.selectedEpisodes[episode.cleanUrl]) this.checkSetIsSelectedAll() }, submit() { var episodesToDownload = [] if (this.episodesSelected.length) { - episodesToDownload = this.episodesSelected.map((episodeIndex) => this.episodes[Number(episodeIndex)]) + episodesToDownload = this.episodesSelected.map((cleanUrl) => this.episodesCleaned.find((ep) => ep.cleanUrl == cleanUrl)) } var payloadSize = JSON.stringify(episodesToDownload).length @@ -185,7 +184,15 @@ export default { }) }, init() { - this.episodes.sort((a, b) => (a.publishedAt < b.publishedAt ? 1 : -1)) + this.episodesCleaned = this.episodes + .filter((ep) => ep.enclosure?.url) + .map((_ep) => { + return { + ..._ep, + cleanUrl: _ep.enclosure.url.split('?')[0] + } + }) + this.episodesCleaned.sort((a, b) => (a.publishedAt < b.publishedAt ? 1 : -1)) this.selectAll = false this.selectedEpisodes = {} }