diff --git a/components/tables/podcast/LatestEpisodeRow.vue b/components/tables/podcast/LatestEpisodeRow.vue
index 7f21553a..f72a9017 100644
--- a/components/tables/podcast/LatestEpisodeRow.vue
+++ b/components/tables/podcast/LatestEpisodeRow.vue
@@ -41,7 +41,7 @@
audio_file
- {{ downloadItem ? 'downloading' : 'download' }}
+ {{ downloadItem || pendingDownload ? 'downloading' : 'download' }}
download_done
@@ -77,6 +77,7 @@ export default {
data() {
return {
isProcessingReadUpdate: false,
+ pendingDownload: false,
processing: false
}
},
@@ -174,14 +175,16 @@ export default {
return folderObj
},
async downloadClick() {
- if (this.downloadItem) return
+ if (this.downloadItem || this.pendingDownload) return
+ this.pendingDownload = true
await this.$hapticsImpact()
if (this.isIos) {
// no local folders on iOS
- this.startDownload()
+ await this.startDownload()
} else {
- this.download()
+ await this.download()
}
+ this.pendingDownload = false
},
async download(selectedLocalFolder = null) {
let localFolder = selectedLocalFolder
@@ -215,7 +218,7 @@ export default {
console.log('Local folder', JSON.stringify(localFolder))
- this.startDownload(localFolder)
+ return this.startDownload(localFolder)
},
async startDownload(localFolder) {
var payload = {
diff --git a/pages/bookshelf/latest.vue b/pages/bookshelf/latest.vue
index 39a17692..5b9b6f96 100644
--- a/pages/bookshelf/latest.vue
+++ b/pages/bookshelf/latest.vue
@@ -16,7 +16,7 @@ export default {
recentEpisodes: [],
totalEpisodes: 0,
currentPage: 0,
- localEpisodeMap: {},
+ localLibraryItems: [],
isLocal: false,
loadedLibraryId: null
}
@@ -25,6 +25,24 @@ export default {
computed: {
currentLibraryId() {
return this.$store.state.libraries.currentLibraryId
+ },
+ localEpisodes() {
+ const episodes = []
+ this.localLibraryItems.forEach((li) => {
+ if (li.media.episodes?.length) {
+ episodes.push(...li.media.episodes)
+ }
+ })
+ return episodes
+ },
+ localEpisodeMap() {
+ var epmap = {}
+ this.localEpisodes.forEach((localEp) => {
+ if (localEp.serverEpisodeId) {
+ epmap[localEp.serverEpisodeId] = localEp
+ }
+ })
+ return epmap
}
},
methods: {
@@ -61,14 +79,31 @@ export default {
this.$router.replace('/bookshelf')
}
}
+ },
+ async loadLocalPodcastLibraryItems() {
+ this.localLibraryItems = await this.$db.getLocalLibraryItems('podcast')
+ },
+ newLocalLibraryItem(item) {
+ if (item.mediaType !== 'podcast') {
+ return
+ }
+ const matchingLocalLibraryItem = this.localLibraryItems.find((lli) => lli.id === item.id)
+ if (matchingLocalLibraryItem) {
+ matchingLocalLibraryItem.media.episodes = item.media.episodes
+ } else {
+ this.localLibraryItems.push(item)
+ }
}
},
mounted() {
this.loadRecentEpisodes()
+ this.loadLocalPodcastLibraryItems()
this.$eventBus.$on('library-changed', this.libraryChanged)
+ this.$eventBus.$on('new-local-library-item', this.newLocalLibraryItem)
},
beforeDestroy() {
this.$eventBus.$off('library-changed', this.libraryChanged)
+ this.$eventBus.$off('new-local-library-item', this.newLocalLibraryItem)
}
}
\ No newline at end of file