diff --git a/client/components/modals/podcast/tabs/EpisodeDetails.vue b/client/components/modals/podcast/tabs/EpisodeDetails.vue index cdc08f2f..1c486c2f 100644 --- a/client/components/modals/podcast/tabs/EpisodeDetails.vue +++ b/client/components/modals/podcast/tabs/EpisodeDetails.vue @@ -24,7 +24,12 @@
Episode URL from RSS feed
@@ -125,26 +130,44 @@ export default { } return updatePayload }, - submit() { - const payload = this.getUpdatePayload() - if (!Object.keys(payload).length) { - return this.$toast.info('No updates were made') + async saveAndClose() { + const wasUpdated = await this.submit() + if (wasUpdated !== null) this.$emit('close') + }, + async submit() { + if (this.isProcessing) { + return null } + const updatedDetails = this.getUpdatePayload() + if (!Object.keys(updatedDetails).length) { + this.$toast.info('No changes were made') + return false + } + return this.updateDetails(updatedDetails) + }, + async updateDetails(updatedDetails) { this.isProcessing = true - this.$axios - .$patch(`/api/podcasts/${this.libraryItem.id}/episode/${this.episodeId}`, payload) - .then(() => { - this.isProcessing = false + 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 + }); + + this.isProcessing = false + if (updateResult) { + if (updateResult) { this.$toast.success('Podcast episode updated') - this.$emit('close') - }) - .catch((error) => { - var 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 true + } else { + this.$toast.info(this.$strings.MessageNoUpdatesWereNecessary) + } + } + return false } }, mounted() {}