diff --git a/client/components/modals/podcast/EpisodeFeed.vue b/client/components/modals/podcast/EpisodeFeed.vue
index 3e995b06..642a6e0e 100644
--- a/client/components/modals/podcast/EpisodeFeed.vue
+++ b/client/components/modals/podcast/EpisodeFeed.vue
@@ -11,32 +11,25 @@
v-for="(episode, index) in episodes"
:key="index"
class="relative"
- :class="episode.enclosure && itemEpisodeMap[episode.enclosure.url] ? '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'"
-
+ :class="itemEpisodeMap[episode.enclosure.url] ? '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)"
>
- download_done
-
+ download_done
+
#{{ episode.episode }}
{{ episode.title }}
{{ episode.subtitle }}
Published {{ episode.publishedAt ? $dateDistanceFromNow(episode.publishedAt) : 'Unknown' }}
-
-
-
{{ buttonText }}
+
+
{{ buttonText }}
+
All episodes are downloaded
@@ -58,7 +51,8 @@ export default {
data() {
return {
processing: false,
- selectedEpisodes: {}
+ selectedEpisodes: {},
+ selectAll: false
}
},
watch: {
@@ -78,22 +72,12 @@ export default {
this.$emit('input', val)
}
},
- selectAll: {
- get() {
- return this.episodesSelected.length == this.episodes.filter((_, index) => !(this.episodes[index].enclosure && this.itemEpisodeMap[this.episodes[index].enclosure.url])).length
- },
- set(val) {
- for (const key in this.selectedEpisodes) {
- this.selectedEpisodes[key] = val
- }
- }
- },
title() {
if (!this.libraryItem) return ''
return this.libraryItem.media.metadata.title || 'Unknown'
},
allDownloaded() {
- return Object.values(this.episodes).filter((episode) => !(episode.enclosure && this.itemEpisodeMap[episode.enclosure.url])).length === 0
+ return !this.episodes.some((episode) => !this.itemEpisodeMap[episode.enclosure.url])
},
episodesSelected() {
return Object.keys(this.selectedEpisodes).filter((key) => !!this.selectedEpisodes[key])
@@ -115,18 +99,33 @@ export default {
}
},
methods: {
- toggleSelectEpisode(index) {
- this.$set(this.selectedEpisodes, String(index), !this.selectedEpisodes[String(index)])
+ toggleSelectAll(val) {
+ for (let i = 0; i < this.episodes.length; i++) {
+ const episode = this.episodes[i]
+ if (this.itemEpisodeMap[episode.enclosure.url]) this.selectedEpisodes[String(i)] = false
+ else this.$set(this.selectedEpisodes, String(i), val)
+ }
},
- clearSelectedEpisodes() {
- Object.keys(this.selectedEpisodes).forEach((key, idx) => this.$set(this.selectedEpisodes, String(idx), false))
+ checkSetIsSelectedAll() {
+ for (let i = 0; i < this.episodes.length; i++) {
+ const episode = this.episodes[i]
+ if (!this.itemEpisodeMap[episode.enclosure.url] && !this.selectedEpisodes[String(i)]) {
+ this.selectAll = false
+ return
+ }
+ }
+ this.selectAll = true
+ },
+ toggleSelectEpisode(index, episode) {
+ if (this.itemEpisodeMap[episode.enclosure.url]) return
+ this.$set(this.selectedEpisodes, String(index), !this.selectedEpisodes[String(index)])
+ this.checkSetIsSelectedAll()
},
submit() {
var episodesToDownload = []
if (this.episodesSelected.length) {
episodesToDownload = this.episodesSelected.map((episodeIndex) => this.episodes[Number(episodeIndex)])
}
- this.clearSelectedEpisodes()
var payloadSize = JSON.stringify(episodesToDownload).length
var sizeInMb = payloadSize / 1024 / 1024
@@ -149,17 +148,15 @@ export default {
console.error('Failed to download episodes', error)
this.processing = false
this.$toast.error(errorMsg)
+
+ this.selectedEpisodes = {}
+ this.selectAll = false
})
},
init() {
- this.episodes.sort((a, b) => (a.publishedAt < b.publishedAt) ? 1 : -1)
- for (let i = 0; i < this.episodes.length; i++) {
- var episode = this.episodes[i]
- if (episode.enclosure && !this.itemEpisodeMap[episode.enclosure.url]) {
- // Do not include episodes already downloaded
- this.$set(this.selectedEpisodes, String(i), false)
- }
- }
+ this.episodes.sort((a, b) => (a.publishedAt < b.publishedAt ? 1 : -1))
+ this.selectAll = false
+ this.selectedEpisodes = {}
}
},
mounted() {}