diff --git a/client/components/modals/podcast/EditEpisode.vue b/client/components/modals/podcast/EditEpisode.vue index e2126be2..ed9c8f28 100644 --- a/client/components/modals/podcast/EditEpisode.vue +++ b/client/components/modals/podcast/EditEpisode.vue @@ -48,7 +48,7 @@ export default { show: { handler(newVal) { if (newVal) { - const availableTabIds = this.tabs.map((tab) => tab.id); + const availableTabIds = this.tabs.map((tab) => tab.id) if (!availableTabIds.length) { this.show = false return @@ -94,11 +94,10 @@ export default { return this.episode.id }, title() { - if (!this.libraryItem) return '' - return this.libraryItem.media.metadata.title || 'Unknown' + return this.libraryItem?.media.metadata.title || 'Unknown' }, tabComponentName() { - const _tab = this.tabs.find((t) => t.id === this.selectedTab); + const _tab = this.tabs.find((t) => t.id === this.selectedTab) return _tab ? _tab.component : '' }, episodeTableEpisodeIds() { @@ -118,19 +117,17 @@ export default { methods: { async goPrevEpisode() { if (this.currentEpisodeIndex - 1 < 0) return - const prevEpisodeId = this.episodeTableEpisodeIds[this.currentEpisodeIndex - 1]; + const prevEpisodeId = this.episodeTableEpisodeIds[this.currentEpisodeIndex - 1] this.processing = true const prevEpisode = await this.$axios.$get(`/api/podcasts/${this.libraryItem.id}/episode/${prevEpisodeId}`).catch((error) => { - const errorMsg = error.response && error.response.data ? error.response.data : 'Failed to fetch episode'; + const errorMsg = error.response && error.response.data ? error.response.data : 'Failed to fetch episode' this.$toast.error(errorMsg) return null - }); + }) this.processing = false if (prevEpisode) { - this.unregisterListeners() this.episodeItem = prevEpisode this.$store.commit('globals/setSelectedEpisode', prevEpisode) - this.$nextTick(this.registerListeners) } else { console.error('Episode not found', prevEpisodeId) } @@ -138,18 +135,16 @@ export default { async goNextEpisode() { if (this.currentEpisodeIndex >= this.episodeTableEpisodeIds.length - 1) return this.processing = true - const nextEpisodeId = this.episodeTableEpisodeIds[this.currentEpisodeIndex + 1]; + const nextEpisodeId = this.episodeTableEpisodeIds[this.currentEpisodeIndex + 1] const nextEpisode = await this.$axios.$get(`/api/podcasts/${this.libraryItem.id}/episode/${nextEpisodeId}`).catch((error) => { - const errorMsg = error.response && error.response.data ? error.response.data : 'Failed to fetch book'; + const errorMsg = error.response && error.response.data ? error.response.data : 'Failed to fetch book' this.$toast.error(errorMsg) return null - }); + }) this.processing = false if (nextEpisode) { - this.unregisterListeners() this.episodeItem = nextEpisode this.$store.commit('globals/setSelectedEpisode', nextEpisode) - this.$nextTick(this.registerListeners) } else { console.error('Episode not found', nextEpisodeId) } @@ -161,9 +156,6 @@ export default { this.processing = false } }, - libraryItemUpdated(expandedLibraryItem) { - this.libraryItem = expandedLibraryItem - }, init() { this.fetchFull() }, @@ -187,11 +179,9 @@ export default { }, registerListeners() { this.$eventBus.$on('modal-hotkey', this.hotkey) - this.$eventBus.$on(`${this.selectedLibraryItemId}_updated`, this.libraryItemUpdated) }, unregisterListeners() { this.$eventBus.$off('modal-hotkey', this.hotkey) - this.$eventBus.$off(`${this.selectedLibraryItemId}_updated`, this.libraryItemUpdated) } }, mounted() {}, diff --git a/client/components/modals/podcast/tabs/EpisodeDetails.vue b/client/components/modals/podcast/tabs/EpisodeDetails.vue index 1c486c2f..debf9155 100644 --- a/client/components/modals/podcast/tabs/EpisodeDetails.vue +++ b/client/components/modals/podcast/tabs/EpisodeDetails.vue @@ -148,15 +148,12 @@ export default { }, async updateDetails(updatedDetails) { this.isProcessing = true - const updateResult = await this.$axios - .$patch(`/api/podcasts/${this.libraryItem.id}/episode/${this.episodeId}`, updatedDetails) - .catch((error) => { - const errorMsg = error.response && error.response.data ? error.response.data : 'Failed to update episode'; - console.error('Failed update episode', error) - this.isProcessing = false - this.$toast.error(errorMsg) - return false - }); + const updateResult = await this.$axios.$patch(`/api/podcasts/${this.libraryItem.id}/episode/${this.episodeId}`, updatedDetails).catch((error) => { + console.error('Failed update episode', error) + this.isProcessing = false + this.$toast.error(error?.response?.data || 'Failed to update episode') + return false + }) this.isProcessing = false if (updateResult) { diff --git a/client/components/ui/RichTextEditor.vue b/client/components/ui/RichTextEditor.vue index 068bc95f..582f5e8f 100644 --- a/client/components/ui/RichTextEditor.vue +++ b/client/components/ui/RichTextEditor.vue @@ -68,8 +68,6 @@ export default { } }, mounted() {}, - beforeDestroy() { - console.log('Before destroy') - } + beforeDestroy() {} } \ No newline at end of file diff --git a/server/controllers/PodcastController.js b/server/controllers/PodcastController.js index 60f1e35d..f19bba9f 100644 --- a/server/controllers/PodcastController.js +++ b/server/controllers/PodcastController.js @@ -227,13 +227,13 @@ class PodcastController { // GET: api/podcasts/:id/episode/:episodeId async getEpisode(req, res) { - const episodeId = req.params.episodeId; - const libraryItem = req.libraryItem; + const episodeId = req.params.episodeId + const libraryItem = req.libraryItem - const episode = libraryItem.media.episodes.find(ep => ep.id === episodeId); + const episode = libraryItem.media.episodes.find(ep => ep.id === episodeId) if (!episode) { - Logger.error(`[PodcastController] getEpisode episode ${episodeId} not found for item ${libraryItem.id}`) - return res.sendStatus(404) + Logger.error(`[PodcastController] getEpisode episode ${episodeId} not found for item ${libraryItem.id}`) + return res.sendStatus(404) } res.json(episode)