From 88fbebe5c4f00e4d8a363c6b6348b7078c5aaf5d Mon Sep 17 00:00:00 2001 From: advplyr Date: Sat, 25 Nov 2023 14:38:40 -0600 Subject: [PATCH] Fix:Error going to local library item page that is storing an old server library item id when server is now using new ids #953 --- pages/item/_id/index.vue | 5 ++++- plugins/nativeHttp.js | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pages/item/_id/index.vue b/pages/item/_id/index.vue index f5856327..2e8bf7fe 100644 --- a/pages/item/_id/index.vue +++ b/pages/item/_id/index.vue @@ -169,7 +169,10 @@ export default { libraryItem = await app.$db.getLocalLibraryItem(libraryItemId) console.log('Got lli', libraryItemId) // If library item is linked to the currently connected server then redirect to the page using the server library item id - if (libraryItem?.libraryItemId && libraryItem?.serverAddress === store.getters['user/getServerAddress'] && store.state.networkConnected) { + if (libraryItem?.libraryItemId?.startsWith('li_')) { + // Detect old library item id + console.error('Local library item has old server library item id', libraryItem.libraryItemId) + } else if (libraryItem?.libraryItemId && libraryItem?.serverAddress === store.getters['user/getServerAddress'] && store.state.networkConnected) { let query = '' if (libraryItem.mediaType === 'podcast') query = '?episodefilter=downloaded' // Filter by downloaded when redirecting from the local copy return redirect(`/item/${libraryItem.libraryItemId}${query}`) diff --git a/plugins/nativeHttp.js b/plugins/nativeHttp.js index d1983dce..f2586dc2 100644 --- a/plugins/nativeHttp.js +++ b/plugins/nativeHttp.js @@ -27,7 +27,13 @@ export default function ({ store }, inject) { data, headers, ...options - }).then(res => res.data) + }).then(res => { + if (res.status >= 400) { + console.error(`[nativeHttp] ${res.status} status for url "${url}"`) + throw new Error(res.data) + } + return res.data + }) }, get(url, options = {}) { return this.request('GET', url, undefined, options)