Fix:Series bookshelf to use books/all api endpoint and limit books per request #264

This commit is contained in:
advplyr 2021-12-26 14:40:00 -06:00
parent 0e656dfdd0
commit 6b9ce453b9

View File

@ -217,10 +217,10 @@ export default {
this.currentSFQueryString = this.buildSearchParams() this.currentSFQueryString = this.buildSearchParams()
} }
var entityPath = this.entityName === 'books' ? `books/all` : this.entityName var entityPath = this.entityName === 'books' || this.entityName === 'series-books' ? `books/all` : this.entityName
if (this.entityName === 'series-books') entityPath = `series/${this.seriesId}`
var sfQueryString = this.currentSFQueryString ? this.currentSFQueryString + '&' : '' var sfQueryString = this.currentSFQueryString ? this.currentSFQueryString + '&' : ''
var fullQueryString = this.entityName === 'series-books' ? '' : `?${sfQueryString}limit=${this.booksPerFetch}&page=${page}&minified=1` var fullQueryString = `?${sfQueryString}limit=${this.booksPerFetch}&page=${page}&minified=1`
var payload = await this.$axios.$get(`/api/libraries/${this.currentLibraryId}/${entityPath}${fullQueryString}`).catch((error) => { var payload = await this.$axios.$get(`/api/libraries/${this.currentLibraryId}/${entityPath}${fullQueryString}`).catch((error) => {
console.error('failed to fetch books', error) console.error('failed to fetch books', error)
return null return null
@ -345,11 +345,16 @@ export default {
this.$nextTick(this.remountEntities) this.$nextTick(this.remountEntities)
}, },
buildSearchParams() { buildSearchParams() {
if (this.page === 'search' || this.page === 'series' || this.page === 'collections' || this.page === 'series-books') { if (this.page === 'search' || this.page === 'series' || this.page === 'collections') {
return '' return ''
} }
let searchParams = new URLSearchParams() let searchParams = new URLSearchParams()
if (this.page === 'series-books') {
searchParams.set('filter', `series.${this.seriesId}`)
searchParams.set('sort', 'book.volumeNumber')
searchParams.set('desc', 0)
} else {
if (this.filterBy && this.filterBy !== 'all') { if (this.filterBy && this.filterBy !== 'all') {
searchParams.set('filter', this.filterBy) searchParams.set('filter', this.filterBy)
} }
@ -357,9 +362,12 @@ export default {
searchParams.set('sort', this.orderBy) searchParams.set('sort', this.orderBy)
searchParams.set('desc', this.orderDesc ? 1 : 0) searchParams.set('desc', this.orderDesc ? 1 : 0)
} }
}
return searchParams.toString() return searchParams.toString()
}, },
checkUpdateSearchParams() { checkUpdateSearchParams() {
if (this.page === 'series-books') return false
var newSearchParams = this.buildSearchParams() var newSearchParams = this.buildSearchParams()
var currentQueryString = window.location.search var currentQueryString = window.location.search
if (currentQueryString && currentQueryString.startsWith('?')) currentQueryString = currentQueryString.slice(1) if (currentQueryString && currentQueryString.startsWith('?')) currentQueryString = currentQueryString.slice(1)