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 |       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,12 +164,15 @@ 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 | ||||||
|         const errorMsg = error.response.data || 'Failed to get items' |         .$post(`/api/items/batch/get`, { libraryItemIds }) | ||||||
|         console.error(errorMsg, error) |         .then((res) => res.libraryItems) | ||||||
|         this.$toast.error(errorMsg) |         .catch((error) => { | ||||||
|         return [] |           const errorMsg = error.response.data || 'Failed to get items' | ||||||
|       }) |           console.error(errorMsg, error) | ||||||
|  |           this.$toast.error(errorMsg) | ||||||
|  |           return [] | ||||||
|  |         }) | ||||||
| 
 | 
 | ||||||
|       if (!libraryItems.length) { |       if (!libraryItems.length) { | ||||||
|         this.$store.commit('setProcessingBatch', false) |         this.$store.commit('setProcessingBatch', false) | ||||||
|  | |||||||
| @ -96,11 +96,14 @@ 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 | ||||||
|       const errorMsg = error.response.data || 'Failed to get items' |       .$post(`/api/items/batch/get`, { libraryItemIds }) | ||||||
|       console.error(errorMsg, error) |       .then((res) => res.libraryItems) | ||||||
|       return [] |       .catch((error) => { | ||||||
|     }) |         const errorMsg = error.response.data || 'Failed to get items' | ||||||
|  |         console.error(errorMsg, error) | ||||||
|  |         return [] | ||||||
|  |       }) | ||||||
|     return { |     return { | ||||||
|       mediaType: libraryItems[0].mediaType, |       mediaType: libraryItems[0].mediaType, | ||||||
|       libraryItems |       libraryItems | ||||||
|  | |||||||
| @ -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