mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01: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 | ||||
|     }, | ||||
|     selectedMediaItemsArePlayable() { | ||||
|       return !this.selectedMediaItems.some(i => !i.hasTracks) | ||||
|       return !this.selectedMediaItems.some((i) => !i.hasTracks) | ||||
|     }, | ||||
|     userMediaProgress() { | ||||
|       return this.$store.state.user.user.mediaProgress || [] | ||||
| @ -164,12 +164,15 @@ export default { | ||||
|       this.$store.commit('setProcessingBatch', true) | ||||
| 
 | ||||
|       const libraryItemIds = this.selectedMediaItems.map((i) => i.id) | ||||
|       const libraryItems = await this.$axios.$post(`/api/items/batch/get`, { libraryItemIds }).catch((error) => { | ||||
|         const errorMsg = error.response.data || 'Failed to get items' | ||||
|         console.error(errorMsg, error) | ||||
|         this.$toast.error(errorMsg) | ||||
|         return [] | ||||
|       }) | ||||
|       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' | ||||
|           console.error(errorMsg, error) | ||||
|           this.$toast.error(errorMsg) | ||||
|           return [] | ||||
|         }) | ||||
| 
 | ||||
|       if (!libraryItems.length) { | ||||
|         this.$store.commit('setProcessingBatch', false) | ||||
|  | ||||
| @ -96,11 +96,14 @@ export default { | ||||
|     } | ||||
| 
 | ||||
|     const libraryItemIds = store.state.globals.selectedMediaItems.map((i) => i.id) | ||||
|     const libraryItems = await app.$axios.$post(`/api/items/batch/get`, { libraryItemIds }).catch((error) => { | ||||
|       const errorMsg = error.response.data || 'Failed to get items' | ||||
|       console.error(errorMsg, error) | ||||
|       return [] | ||||
|     }) | ||||
|     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' | ||||
|         console.error(errorMsg, error) | ||||
|         return [] | ||||
|       }) | ||||
|     return { | ||||
|       mediaType: libraryItems[0].mediaType, | ||||
|       libraryItems | ||||
|  | ||||
| @ -308,17 +308,17 @@ class LibraryItemController { | ||||
| 
 | ||||
|   // POST: api/items/batch/get
 | ||||
|   async batchGet(req, res) { | ||||
|     var libraryItemIds = req.body.libraryItemIds || [] | ||||
|     const libraryItemIds = req.body.libraryItemIds || [] | ||||
|     if (!libraryItemIds.length) { | ||||
|       return res.status(403).send('Invalid payload') | ||||
|     } | ||||
|     var libraryItems = [] | ||||
|     const libraryItems = [] | ||||
|     libraryItemIds.forEach((lid) => { | ||||
|       const li = this.db.libraryItems.find(_li => _li.id === lid) | ||||
|       if (li) libraryItems.push(li.toJSONExpanded()) | ||||
|     }) | ||||
|     res.json({ | ||||
|       libraryItems: libraryItems | ||||
|       libraryItems | ||||
|     }) | ||||
|   } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user