mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-05-13 01:19:55 +02:00
Update library items batch get route
This commit is contained in:
parent
3c0fdff7b4
commit
0ae853c119
@ -122,7 +122,7 @@ export default {
|
|||||||
return this.$store.state.globals.selectedMediaItems
|
return this.$store.state.globals.selectedMediaItems
|
||||||
},
|
},
|
||||||
selectedMediaItemsArePlayable() {
|
selectedMediaItemsArePlayable() {
|
||||||
return !this.selectedMediaItems.some(i => !i.hasTracks)
|
return !this.selectedMediaItems.some((i) => !i.hasTracks)
|
||||||
},
|
},
|
||||||
userMediaProgress() {
|
userMediaProgress() {
|
||||||
return this.$store.state.user.user.mediaProgress || []
|
return this.$store.state.user.user.mediaProgress || []
|
||||||
@ -164,7 +164,10 @@ export default {
|
|||||||
this.$store.commit('setProcessingBatch', true)
|
this.$store.commit('setProcessingBatch', true)
|
||||||
|
|
||||||
const libraryItemIds = this.selectedMediaItems.map((i) => i.id)
|
const libraryItemIds = this.selectedMediaItems.map((i) => i.id)
|
||||||
const libraryItems = await this.$axios.$post(`/api/items/batch/get`, { libraryItemIds }).catch((error) => {
|
const libraryItems = await this.$axios
|
||||||
|
.$post(`/api/items/batch/get`, { libraryItemIds })
|
||||||
|
.then((res) => res.libraryItems)
|
||||||
|
.catch((error) => {
|
||||||
const errorMsg = error.response.data || 'Failed to get items'
|
const errorMsg = error.response.data || 'Failed to get items'
|
||||||
console.error(errorMsg, error)
|
console.error(errorMsg, error)
|
||||||
this.$toast.error(errorMsg)
|
this.$toast.error(errorMsg)
|
||||||
|
@ -96,7 +96,10 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const libraryItemIds = store.state.globals.selectedMediaItems.map((i) => i.id)
|
const libraryItemIds = store.state.globals.selectedMediaItems.map((i) => i.id)
|
||||||
const libraryItems = await app.$axios.$post(`/api/items/batch/get`, { libraryItemIds }).catch((error) => {
|
const libraryItems = await app.$axios
|
||||||
|
.$post(`/api/items/batch/get`, { libraryItemIds })
|
||||||
|
.then((res) => res.libraryItems)
|
||||||
|
.catch((error) => {
|
||||||
const errorMsg = error.response.data || 'Failed to get items'
|
const errorMsg = error.response.data || 'Failed to get items'
|
||||||
console.error(errorMsg, error)
|
console.error(errorMsg, error)
|
||||||
return []
|
return []
|
||||||
|
@ -308,17 +308,17 @@ class LibraryItemController {
|
|||||||
|
|
||||||
// POST: api/items/batch/get
|
// POST: api/items/batch/get
|
||||||
async batchGet(req, res) {
|
async batchGet(req, res) {
|
||||||
var libraryItemIds = req.body.libraryItemIds || []
|
const libraryItemIds = req.body.libraryItemIds || []
|
||||||
if (!libraryItemIds.length) {
|
if (!libraryItemIds.length) {
|
||||||
return res.status(403).send('Invalid payload')
|
return res.status(403).send('Invalid payload')
|
||||||
}
|
}
|
||||||
var libraryItems = []
|
const libraryItems = []
|
||||||
libraryItemIds.forEach((lid) => {
|
libraryItemIds.forEach((lid) => {
|
||||||
const li = this.db.libraryItems.find(_li => _li.id === lid)
|
const li = this.db.libraryItems.find(_li => _li.id === lid)
|
||||||
if (li) libraryItems.push(li.toJSONExpanded())
|
if (li) libraryItems.push(li.toJSONExpanded())
|
||||||
})
|
})
|
||||||
res.json({
|
res.json({
|
||||||
libraryItems: libraryItems
|
libraryItems
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user