From 2cc23b6d6bc3a4bf5d02fef018ce32ba5a4bf79a Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 27 May 2023 09:13:44 -0500 Subject: [PATCH] Update:Auto update home page shelves when new episode is added #716 --- client/components/app/BookShelfCategorized.vue | 15 +++++++++++++-- server/managers/PodcastManager.js | 5 +++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/client/components/app/BookShelfCategorized.vue b/client/components/app/BookShelfCategorized.vue index 5b902fb0..19cded4b 100644 --- a/client/components/app/BookShelfCategorized.vue +++ b/client/components/app/BookShelfCategorized.vue @@ -337,8 +337,9 @@ export default { }, libraryItemsAdded(libraryItems) { console.log('libraryItems added', libraryItems) - // TODO: Check if audiobook would be on this shelf - if (!this.search) { + + const isThisLibrary = !libraryItems.some((li) => li.libraryId !== this.currentLibraryId) + if (!this.search && isThisLibrary) { this.fetchCategories() } }, @@ -347,6 +348,14 @@ export default { this.libraryItemUpdated(li) }) }, + episodeAdded(episodeWithLibraryItem) { + console.log('Podcast episode added', episodeWithLibraryItem) + + const isThisLibrary = episodeWithLibraryItem.libraryItem?.libraryId === this.currentLibraryId + if (!this.search && isThisLibrary) { + this.fetchCategories() + } + }, removeAllSeriesFromContinueSeries(seriesIds) { this.shelves.forEach((shelf) => { if (shelf.type == 'book' && shelf.id == 'continue-series') { @@ -407,6 +416,7 @@ export default { this.$root.socket.on('item_removed', this.libraryItemRemoved) this.$root.socket.on('items_updated', this.libraryItemsUpdated) this.$root.socket.on('items_added', this.libraryItemsAdded) + this.$root.socket.on('episode_added', this.episodeAdded) } else { console.error('Error socket not initialized') } @@ -421,6 +431,7 @@ export default { this.$root.socket.off('item_removed', this.libraryItemRemoved) this.$root.socket.off('items_updated', this.libraryItemsUpdated) this.$root.socket.off('items_added', this.libraryItemsAdded) + this.$root.socket.off('episode_added', this.episodeAdded) } else { console.error('Error socket not initialized') } diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index d50bc7bb..713c004c 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -140,8 +140,6 @@ class PodcastManager { async scanAddPodcastEpisodeAudioFile() { const libraryFile = await this.getLibraryFile(this.currentDownload.targetPath, this.currentDownload.targetRelPath) - // TODO: Set meta tags on new audio file - const audioFile = await this.probeAudioFile(libraryFile) if (!audioFile) { return false @@ -178,6 +176,9 @@ class PodcastManager { libraryItem.updatedAt = Date.now() await this.db.updateLibraryItem(libraryItem) SocketAuthority.emitter('item_updated', libraryItem.toJSONExpanded()) + const podcastEpisodeExpanded = podcastEpisode.toJSONExpanded() + podcastEpisodeExpanded.libraryItem = libraryItem.toJSONExpanded() + SocketAuthority.emitter('episode_added', podcastEpisodeExpanded) if (this.currentDownload.isAutoDownload) { // Notifications only for auto downloaded episodes this.notificationManager.onPodcastEpisodeDownloaded(libraryItem, podcastEpisode)