Disable CapacitorHttp and add plugin to replace axios calls #781

This commit is contained in:
advplyr
2023-09-15 17:35:44 -05:00
parent 27bbe40874
commit 57d1fbfa83
21 changed files with 142 additions and 62 deletions
+1 -1
View File
@@ -49,7 +49,7 @@ export default {
async logout() {
await this.$hapticsImpact()
if (this.user) {
await this.$axios.$post('/logout').catch((error) => {
await this.$nativeHttp.post('/logout').catch((error) => {
console.error(error)
})
}
+1 -1
View File
@@ -236,7 +236,7 @@ export default {
console.log('[categories] Local shelves set', this.shelves.length, this.lastLocalFetch)
if (isConnectedToServerWithInternet) {
const categories = await this.$axios.$get(`/api/libraries/${this.currentLibraryId}/personalized?minified=1&include=rssfeed,numEpisodesIncomplete`).catch((error) => {
const categories = await this.$nativeHttp.get(`/api/libraries/${this.currentLibraryId}/personalized?minified=1&include=rssfeed,numEpisodesIncomplete`).catch((error) => {
console.error('[categories] Failed to fetch categories', error)
return []
})
+2 -2
View File
@@ -29,7 +29,7 @@ export default {
},
methods: {
async addEpisodeToPlaylist(episode) {
const libraryItem = await this.$axios.$get(`/api/items/${episode.libraryItemId}`).catch((error) => {
const libraryItem = await this.$nativeHttp.get(`/api/items/${episode.libraryItemId}`).catch((error) => {
console.error('Failed to get library item', error)
this.$toast.error('Failed to get library item')
return null
@@ -42,7 +42,7 @@ export default {
async loadRecentEpisodes(page = 0) {
this.loadedLibraryId = this.currentLibraryId
this.processing = true
const episodePayload = await this.$axios.$get(`/api/libraries/${this.currentLibraryId}/recent-episodes?limit=25&page=${page}`).catch((error) => {
const episodePayload = await this.$nativeHttp.get(`/api/libraries/${this.currentLibraryId}/recent-episodes?limit=25&page=${page}`).catch((error) => {
console.error('Failed to get recent episodes', error)
this.$toast.error('Failed to get recent episodes')
return null
+3 -3
View File
@@ -88,7 +88,7 @@ export default {
},
async checkRSSFeed(rssFeed) {
this.processing = true
var payload = await this.$axios.$post(`/api/podcasts/feed`, { rssFeed }).catch((error) => {
var payload = await this.$nativeHttp.post(`/api/podcasts/feed`, { rssFeed }).catch((error) => {
console.error('Failed to get feed', error)
this.$toast.error('Failed to get podcast feed')
return null
@@ -103,7 +103,7 @@ export default {
async submitSearch(term) {
this.processing = true
this.termSearched = ''
const results = await this.$axios.$get(`/api/search/podcast?term=${encodeURIComponent(term)}`).catch((error) => {
const results = await this.$nativeHttp.get(`/api/search/podcast?term=${encodeURIComponent(term)}`).catch((error) => {
console.error('Search request failed', error)
return []
})
@@ -119,7 +119,7 @@ export default {
return
}
this.processing = true
const payload = await this.$axios.$post(`/api/podcasts/feed`, { rssFeed: podcast.feedUrl }).catch((error) => {
const payload = await this.$nativeHttp.post(`/api/podcasts/feed`, { rssFeed: podcast.feedUrl }).catch((error) => {
console.error('Failed to get feed', error)
this.$toast.error('Failed to get podcast feed')
return null
+1 -1
View File
@@ -503,7 +503,7 @@ export default {
const updatePayload = {
isFinished: !this.userIsFinished
}
this.$axios.$patch(`/api/me/progress/${this.libraryItemId}/${this.episode.id}`, updatePayload).catch((error) => {
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'}`)
})
+1 -1
View File
@@ -100,7 +100,7 @@ export default {
return
}
this.isFetching = true
const results = await this.$axios.$get(`/api/libraries/${this.currentLibraryId}/search?q=${value}&limit=5`).catch((error) => {
const results = await this.$nativeHttp.get(`/api/libraries/${this.currentLibraryId}/search?q=${value}&limit=5`).catch((error) => {
console.error('Search error', error)
return null
})
+1 -1
View File
@@ -99,7 +99,7 @@ export default {
},
methods: {
async init() {
this.listeningStats = await this.$axios.$get(`/api/me/listening-stats`).catch((err) => {
this.listeningStats = await this.$nativeHttp.get(`/api/me/listening-stats`).catch((err) => {
console.error('Failed to load listening sesions', err)
return []
})