From 01178d00bf646a9aac948dd8827ebb85be2326ed Mon Sep 17 00:00:00 2001 From: advplyr Date: Sun, 17 Sep 2023 12:43:50 -0500 Subject: [PATCH] Replace existing axios calls with native https calls --- components/app/AudioPlayerContainer.vue | 4 ++-- components/cards/LazyBookCard.vue | 24 ------------------- components/cards/LazyListBookCard.vue | 24 ------------------- components/forms/NewPodcastForm.vue | 4 ++-- .../modals/PodcastEpisodesFeedModal.vue | 4 ++-- .../modals/playlists/AddCreateModal.vue | 16 ++++++------- components/modals/rssfeeds/RssFeedModal.vue | 8 +++---- components/tables/ebook/EbookFilesTable.vue | 4 ++-- components/tables/podcast/EpisodeRow.vue | 4 ++-- components/tables/podcast/EpisodesTable.vue | 4 ++-- .../tables/podcast/LatestEpisodeRow.vue | 4 ++-- pages/bookshelf/authors.vue | 4 ++-- pages/item/_id/_episode/index.vue | 8 +++---- pages/item/_id/index.vue | 8 +++---- store/libraries.js | 8 +++---- 15 files changed, 40 insertions(+), 88 deletions(-) diff --git a/components/app/AudioPlayerContainer.vue b/components/app/AudioPlayerContainer.vue index 757c39f3..f3c13535 100644 --- a/components/app/AudioPlayerContainer.vue +++ b/components/app/AudioPlayerContainer.vue @@ -317,8 +317,8 @@ export default { const libraryItemId = playbackSession.libraryItemId const episodeId = playbackSession.episodeId const url = episodeId ? `/api/me/progress/${libraryItemId}/${episodeId}` : `/api/me/progress/${libraryItemId}` - this.$axios - .$get(url) + this.$nativeHttp + .get(url) .then((data) => { if (!this.$refs.audioPlayer?.isPlaying && data.libraryItemId === libraryItemId) { console.log('[AudioPlayerContainer] device visibility: got server media progress', data.currentTime, 'last time in player is', this.currentTime) diff --git a/components/cards/LazyBookCard.vue b/components/cards/LazyBookCard.vue index c47dd986..11421f69 100644 --- a/components/cards/LazyBookCard.vue +++ b/components/cards/LazyBookCard.vue @@ -123,7 +123,6 @@ export default { isProcessingReadUpdate: false, libraryItem: null, imageReady: false, - rescanning: false, selected: false, isSelectionMode: false, showCoverBg: false, @@ -488,29 +487,6 @@ export default { editClick() { this.$emit('edit', this.libraryItem) }, - rescan() { - this.rescanning = true - this.$axios - .$get(`/api/items/${this.libraryItemId}/scan`) - .then((data) => { - this.rescanning = false - var result = data.result - if (!result) { - this.$toast.error(`Re-Scan Failed for "${this.title}"`) - } else if (result === 'UPDATED') { - this.$toast.success(`Re-Scan complete item was updated`) - } else if (result === 'UPTODATE') { - this.$toast.success(`Re-Scan complete item was up to date`) - } else if (result === 'REMOVED') { - this.$toast.error(`Re-Scan complete item was removed`) - } - }) - .catch((error) => { - console.error('Failed to scan library item', error) - this.$toast.error('Failed to scan library item') - this.rescanning = false - }) - }, showEditModalTracks() { // More menu func this.store.commit('showEditModalOnTab', { libraryItem: this.libraryItem, tab: 'tracks' }) diff --git a/components/cards/LazyListBookCard.vue b/components/cards/LazyListBookCard.vue index f7363c2c..333507d9 100644 --- a/components/cards/LazyListBookCard.vue +++ b/components/cards/LazyListBookCard.vue @@ -62,7 +62,6 @@ export default { isProcessingReadUpdate: false, libraryItem: null, imageReady: false, - rescanning: false, selected: false, isSelectionMode: false, showCoverBg: false, @@ -349,29 +348,6 @@ export default { editClick() { this.$emit('edit', this.libraryItem) }, - rescan() { - this.rescanning = true - this.$axios - .$get(`/api/items/${this.libraryItemId}/scan`) - .then((data) => { - this.rescanning = false - var result = data.result - if (!result) { - this.$toast.error(`Re-Scan Failed for "${this.title}"`) - } else if (result === 'UPDATED') { - this.$toast.success(`Re-Scan complete item was updated`) - } else if (result === 'UPTODATE') { - this.$toast.success(`Re-Scan complete item was up to date`) - } else if (result === 'REMOVED') { - this.$toast.error(`Re-Scan complete item was removed`) - } - }) - .catch((error) => { - console.error('Failed to scan library item', error) - this.$toast.error('Failed to scan library item') - this.rescanning = false - }) - }, showEditModalTracks() { // More menu func this.store.commit('showEditModalOnTab', { libraryItem: this.libraryItem, tab: 'tracks' }) diff --git a/components/forms/NewPodcastForm.vue b/components/forms/NewPodcastForm.vue index a91e4661..9583d9d1 100644 --- a/components/forms/NewPodcastForm.vue +++ b/components/forms/NewPodcastForm.vue @@ -140,8 +140,8 @@ export default { console.log('Podcast payload', podcastPayload) this._processing = true - this.$axios - .$post('/api/podcasts', podcastPayload) + this.$nativeHttp + .post('/api/podcasts', podcastPayload) .then((libraryItem) => { this._processing = false this.$toast.success('Podcast added') diff --git a/components/modals/PodcastEpisodesFeedModal.vue b/components/modals/PodcastEpisodesFeedModal.vue index 8c55a074..7d0b9676 100644 --- a/components/modals/PodcastEpisodesFeedModal.vue +++ b/components/modals/PodcastEpisodesFeedModal.vue @@ -96,8 +96,8 @@ export default { } this.processing = true - this.$axios - .$post(`/api/podcasts/${this.libraryItem.id}/download-episodes`, episodesToDownload) + this.$nativeHttp + .post(`/api/podcasts/${this.libraryItem.id}/download-episodes`, episodesToDownload) .then(() => { this.processing = false this.$toast.success('Started downloading episodes on server') diff --git a/components/modals/playlists/AddCreateModal.vue b/components/modals/playlists/AddCreateModal.vue index 8a4f3f10..f7c3511d 100644 --- a/components/modals/playlists/AddCreateModal.vue +++ b/components/modals/playlists/AddCreateModal.vue @@ -109,8 +109,8 @@ export default { }, loadPlaylists() { this.loading = true - this.$axios - .$get(`/api/libraries/${this.currentLibraryId}/playlists`) + this.$nativeHttp + .get(`/api/libraries/${this.currentLibraryId}/playlists`) .then((data) => { this.playlists = data.results || [] }) @@ -135,8 +135,8 @@ export default { this.processing = true const itemObjects = this.selectedPlaylistItems.map((pi) => ({ libraryItemId: pi.libraryItem.id, episodeId: pi.episode ? pi.episode.id : null })) - this.$axios - .$post(`/api/playlists/${playlist.id}/batch/remove`, { items: itemObjects }) + this.$nativeHttp + .post(`/api/playlists/${playlist.id}/batch/remove`, { items: itemObjects }) .then((updatedPlaylist) => { console.log(`Items removed from playlist`, updatedPlaylist) }) @@ -153,8 +153,8 @@ export default { this.processing = true const itemObjects = this.selectedPlaylistItems.map((pi) => ({ libraryItemId: pi.libraryItem.id, episodeId: pi.episode ? pi.episode.id : null })) - this.$axios - .$post(`/api/playlists/${playlist.id}/batch/add`, { items: itemObjects }) + this.$nativeHttp + .post(`/api/playlists/${playlist.id}/batch/add`, { items: itemObjects }) .then((updatedPlaylist) => { console.log(`Items added to playlist`, updatedPlaylist) }) @@ -184,8 +184,8 @@ export default { name: this.newPlaylistName } - this.$axios - .$post('/api/playlists', newPlaylist) + this.$nativeHttp + .post('/api/playlists', newPlaylist) .then((data) => { console.log('New playlist created', data) this.newPlaylistName = '' diff --git a/components/modals/rssfeeds/RssFeedModal.vue b/components/modals/rssfeeds/RssFeedModal.vue index aaca95d1..6ba27753 100644 --- a/components/modals/rssfeeds/RssFeedModal.vue +++ b/components/modals/rssfeeds/RssFeedModal.vue @@ -145,8 +145,8 @@ export default { } console.log('Payload', payload) - this.$axios - .$post(`/api/feeds/${this.entityType}/${this.entityId}/open`, payload) + this.$nativeHttp + .post(`/api/feeds/${this.entityType}/${this.entityId}/open`, payload) .then((data) => { console.log('Opened RSS Feed', data) this.currentFeed = data.feed @@ -163,8 +163,8 @@ export default { }, closeFeed() { this.processing = true - this.$axios - .$post(`/api/feeds/${this.currentFeed.id}/close`) + this.$nativeHttp + .post(`/api/feeds/${this.currentFeed.id}/close`) .then(() => { this.$toast.success(this.$strings.ToastRSSFeedCloseSuccess) this.show = false diff --git a/components/tables/ebook/EbookFilesTable.vue b/components/tables/ebook/EbookFilesTable.vue index 9c075ce3..2ad2cdde 100644 --- a/components/tables/ebook/EbookFilesTable.vue +++ b/components/tables/ebook/EbookFilesTable.vue @@ -83,8 +83,8 @@ export default { }, updateEbookStatus() { this.processing = true - this.$axios - .$patch(`/api/items/${this.libraryItemId}/ebook/${this.selectedFile.ino}/status`) + this.$nativeHttp + .patch(`/api/items/${this.libraryItemId}/ebook/${this.selectedFile.ino}/status`) .then(() => { this.$toast.success('Ebook updated') }) diff --git a/components/tables/podcast/EpisodeRow.vue b/components/tables/podcast/EpisodeRow.vue index 75e12ae3..0f6797d3 100644 --- a/components/tables/podcast/EpisodeRow.vue +++ b/components/tables/podcast/EpisodeRow.vue @@ -280,8 +280,8 @@ export default { const updatePayload = { isFinished: !this.userIsFinished } - this.$axios - .$patch(`/api/me/progress/${this.libraryItemId}/${this.episode.id}`, updatePayload) + this.$nativeHttp + .patch(`/api/me/progress/${this.libraryItemId}/${this.episode.id}`, updatePayload) .catch((error) => { console.error('Failed', error) this.$toast.error(`Failed to mark as ${updatePayload.isFinished ? 'Finished' : 'Not Finished'}`) diff --git a/components/tables/podcast/EpisodesTable.vue b/components/tables/podcast/EpisodesTable.vue index 71f2ce55..3608a01e 100644 --- a/components/tables/podcast/EpisodesTable.vue +++ b/components/tables/podcast/EpisodesTable.vue @@ -209,8 +209,8 @@ export default { }) if (value) { - this.$axios - .$get(`/api/podcasts/${this.libraryItemId}/clear-queue`) + this.$nativeHttp + .get(`/api/podcasts/${this.libraryItemId}/clear-queue`) .then(() => { this.$toast.success('Episode download queue cleared') this.episodeDownloadQueued = [] diff --git a/components/tables/podcast/LatestEpisodeRow.vue b/components/tables/podcast/LatestEpisodeRow.vue index e662c544..699d76b2 100644 --- a/components/tables/podcast/LatestEpisodeRow.vue +++ b/components/tables/podcast/LatestEpisodeRow.vue @@ -286,8 +286,8 @@ export default { const updatePayload = { isFinished: !this.userIsFinished } - this.$axios - .$patch(`/api/me/progress/${this.libraryItemId}/${this.episode.id}`, updatePayload) + this.$nativeHttp + .patch(`/api/me/progress/${this.libraryItemId}/${this.episode.id}`, updatePayload) .catch((error) => { console.error('Failed', error) this.$toast.error(`Failed to mark as ${updatePayload.isFinished ? 'Finished' : 'Not Finished'}`) diff --git a/pages/bookshelf/authors.vue b/pages/bookshelf/authors.vue index 20803418..fdffd948 100644 --- a/pages/bookshelf/authors.vue +++ b/pages/bookshelf/authors.vue @@ -30,8 +30,8 @@ export default { return } this.loadedLibraryId = this.currentLibraryId - this.authors = await this.$axios - .$get(`/api/libraries/${this.currentLibraryId}/authors`) + this.authors = await this.$nativeHttp + .get(`/api/libraries/${this.currentLibraryId}/authors`) .then((response) => response.authors) .catch((error) => { console.error('Failed to load authors', error) diff --git a/pages/item/_id/_episode/index.vue b/pages/item/_id/_episode/index.vue index ea8d636c..0da75fb5 100644 --- a/pages/item/_id/_episode/index.vue +++ b/pages/item/_id/_episode/index.vue @@ -465,8 +465,8 @@ export default { } if (serverItemProgressId) { - await this.$axios - .$delete(`/api/me/progress/${serverItemProgressId}`) + await this.$nativeHttp + .delete(`/api/me/progress/${serverItemProgressId}`) .then(() => { console.log('Progress reset complete') this.$toast.success(`Your progress was reset`) @@ -519,8 +519,8 @@ export default { if (value) { this.processing = true - this.$axios - .$delete(`/api/podcasts/${this.serverLibraryItemId}/episode/${this.serverEpisodeId}?hard=1`) + this.$nativeHttp + .delete(`/api/podcasts/${this.serverLibraryItemId}/episode/${this.serverEpisodeId}?hard=1`) .then(() => { this.$toast.success('Episode deleted from server') this.$router.replace(`/item/${this.serverLibraryItemId}`) diff --git a/pages/item/_id/index.vue b/pages/item/_id/index.vue index a412baed..b4f76ffb 100644 --- a/pages/item/_id/index.vue +++ b/pages/item/_id/index.vue @@ -651,8 +651,8 @@ export default { } if (this.serverLibraryItemId && serverMediaProgressId) { - await this.$axios - .$delete(`/api/me/progress/${serverMediaProgressId}`) + await this.$nativeHttp + .delete(`/api/me/progress/${serverMediaProgressId}`) .then(() => { console.log('Progress reset complete') this.$toast.success(`Your progress was reset`) @@ -798,8 +798,8 @@ export default { const updatePayload = { isFinished: !this.userIsFinished } - this.$axios - .$patch(`/api/me/progress/${this.libraryItemId}`, updatePayload) + this.$nativeHttp + .patch(`/api/me/progress/${this.libraryItemId}`, updatePayload) .catch((error) => { console.error('Failed', error) this.$toast.error(`Failed to mark as ${updatePayload.isFinished ? 'Finished' : 'Not Finished'}`) diff --git a/store/libraries.js b/store/libraries.js index c5224422..9582653e 100644 --- a/store/libraries.js +++ b/store/libraries.js @@ -39,8 +39,8 @@ export const actions = { return false } - return this.$axios - .$get(`/api/libraries/${libraryId}?include=filterdata`) + return this.$nativeHttp + .get(`/api/libraries/${libraryId}?include=filterdata`) .then((data) => { const library = data.library const filterData = data.filterdata @@ -75,8 +75,8 @@ export const actions = { return false } - return this.$axios - .$get(`/api/libraries`) + return this.$nativeHttp + .get(`/api/libraries`) .then((data) => { // TODO: Server release 2.2.9 changed response to an object. Remove after a few releases const libraries = data.libraries || data