mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	Add:Remove episodes from continue listening shelf #919
This commit is contained in:
		
							parent
							
								
									98e79f144c
								
							
						
					
					
						commit
						63c55f08dc
					
				| @ -19,7 +19,7 @@ | ||||
|         <widgets-item-slider v-if="shelf.type === 'book' || shelf.type === 'podcast'" :key="index + '.'" :items="shelf.entities" :continue-listening-shelf="shelf.id === 'continue-listening'" :height="232 * sizeMultiplier" class="bookshelf-row pl-8 my-6"> | ||||
|           <p class="font-semibold text-gray-100" :style="{ fontSize: sizeMultiplier + 'rem' }">{{ shelf.label }}</p> | ||||
|         </widgets-item-slider> | ||||
|         <widgets-episode-slider v-else-if="shelf.type === 'episode'" :key="index + '.'" :items="shelf.entities" :height="232 * sizeMultiplier" class="bookshelf-row pl-8 my-6"> | ||||
|         <widgets-episode-slider v-else-if="shelf.type === 'episode'" :key="index + '.'" :items="shelf.entities" :continue-listening-shelf="shelf.id === 'continue-listening'" :height="232 * sizeMultiplier" class="bookshelf-row pl-8 my-6"> | ||||
|           <p class="font-semibold text-gray-100" :style="{ fontSize: sizeMultiplier + 'rem' }">{{ shelf.label }}</p> | ||||
|         </widgets-episode-slider> | ||||
|         <widgets-series-slider v-else-if="shelf.type === 'series'" :key="index + '.'" :items="shelf.entities" :height="232 * sizeMultiplier" class="bookshelf-row pl-8 my-6"> | ||||
| @ -175,7 +175,6 @@ export default { | ||||
|       } | ||||
|       this.shelves = shelves | ||||
|     }, | ||||
|     settingsUpdated(settings) {}, | ||||
|     scan() { | ||||
|       this.$store | ||||
|         .dispatch('libraries/requestLibraryScan', { libraryId: this.$store.state.libraries.currentLibraryId }) | ||||
| @ -192,8 +191,8 @@ export default { | ||||
|         this.removeAllSeriesFromContinueSeries(user.seriesHideFromContinueListening) | ||||
|       } | ||||
|       if (user.mediaProgress.length) { | ||||
|         const libraryItemsToHide = user.mediaProgress.filter((mp) => mp.hideFromContinueListening).map((mp) => mp.libraryItemId) | ||||
|         this.removeAllItemsFromContinueListening(libraryItemsToHide) | ||||
|         const mediaProgressToHide = user.mediaProgress.filter((mp) => mp.hideFromContinueListening) | ||||
|         this.removeItemsFromContinueListening(mediaProgressToHide) | ||||
|       } | ||||
|     }, | ||||
|     libraryItemAdded(libraryItem) { | ||||
| @ -264,16 +263,33 @@ export default { | ||||
|         } | ||||
|       }) | ||||
|     }, | ||||
|     removeAllItemsFromContinueListening(itemIds) { | ||||
|       this.shelves.forEach((shelf) => { | ||||
|         if (shelf.type == 'book' && shelf.id == 'continue-listening') { | ||||
|           // Filter out books from continue listening shelf | ||||
|           shelf.entities = shelf.entities.filter((ent) => { | ||||
|             if (itemIds.includes(ent.id)) return false | ||||
|     removeItemsFromContinueListening(mediaProgressItems) { | ||||
|       const continueListeningShelf = this.shelves.find((s) => s.id === 'continue-listening') | ||||
|       if (continueListeningShelf) { | ||||
|         if (continueListeningShelf.type === 'book') { | ||||
|           continueListeningShelf.entities = continueListeningShelf.entities.filter((ent) => { | ||||
|             if (mediaProgressItems.some((mp) => mp.libraryItemId === ent.id)) return false | ||||
|             return true | ||||
|           }) | ||||
|         } else if (continueListeningShelf.type === 'episode') { | ||||
|           continueListeningShelf.entities = continueListeningShelf.entities.filter((ent) => { | ||||
|             if (!ent.recentEpisode) return true // Should always have this here | ||||
|             if (mediaProgressItems.some((mp) => mp.libraryItemId === ent.id && mp.episodeId === ent.recentEpisode.id)) return false | ||||
|             return true | ||||
|           }) | ||||
|         } | ||||
|       }) | ||||
|       } | ||||
|       // this.shelves.forEach((shelf) => { | ||||
|       //   if (shelf.id == 'continue-listening') { | ||||
|       //     if (shelf.type == 'book') { | ||||
|       //       // Filter out books from continue listening shelf | ||||
|       //       shelf.entities = shelf.entities.filter((ent) => { | ||||
|       //         if (mediaProgressItems.some(mp => mp.libraryItemId === ent.id)) return false | ||||
|       //         return true | ||||
|       //       }) | ||||
|       //     } | ||||
|       //   } | ||||
|       // }) | ||||
|     }, | ||||
|     authorUpdated(author) { | ||||
|       this.shelves.forEach((shelf) => { | ||||
| @ -298,8 +314,6 @@ export default { | ||||
|       }) | ||||
|     }, | ||||
|     initListeners() { | ||||
|       this.$store.commit('user/addSettingsListener', { id: 'bookshelf', meth: this.settingsUpdated }) | ||||
| 
 | ||||
|       if (this.$root.socket) { | ||||
|         this.$root.socket.on('user_updated', this.userUpdated) | ||||
|         this.$root.socket.on('author_updated', this.authorUpdated) | ||||
|  | ||||
| @ -9,7 +9,21 @@ | ||||
|         </div> | ||||
|         <div v-if="shelf.type === 'episode'" class="flex items-center"> | ||||
|           <template v-for="(entity, index) in shelf.entities"> | ||||
|             <cards-lazy-book-card :key="entity.recentEpisode.id" :ref="`shelf-episode-${entity.recentEpisode.id}`" :index="index" :width="bookCoverWidth" :height="bookCoverHeight" :book-cover-aspect-ratio="bookCoverAspectRatio" :book-mount="entity" class="relative mx-2" @hook:updated="updatedBookCard" @select="selectItem" @editPodcast="editItem" @edit="editEpisode" /> | ||||
|             <cards-lazy-book-card | ||||
|               :key="entity.recentEpisode.id" | ||||
|               :ref="`shelf-episode-${entity.recentEpisode.id}`" | ||||
|               :index="index" | ||||
|               :width="bookCoverWidth" | ||||
|               :height="bookCoverHeight" | ||||
|               :book-cover-aspect-ratio="bookCoverAspectRatio" | ||||
|               :book-mount="entity" | ||||
|               :continue-listening-shelf="continueListeningShelf" | ||||
|               class="relative mx-2" | ||||
|               @hook:updated="updatedBookCard" | ||||
|               @select="selectItem" | ||||
|               @editPodcast="editItem" | ||||
|               @edit="editEpisode" | ||||
|             /> | ||||
|           </template> | ||||
|         </div> | ||||
|         <div v-if="shelf.type === 'series'" class="flex items-center"> | ||||
|  | ||||
| @ -379,6 +379,12 @@ export default { | ||||
|             text: `Mark as ${this.itemIsFinished ? 'Not Finished' : 'Finished'}` | ||||
|           } | ||||
|         ] | ||||
|         if (this.continueListeningShelf) { | ||||
|           items.push({ | ||||
|             func: 'removeFromContinueListening', | ||||
|             text: 'Remove from Continue Listening' | ||||
|           }) | ||||
|         } | ||||
|         return items | ||||
|       } | ||||
| 
 | ||||
| @ -630,7 +636,7 @@ export default { | ||||
|           console.log('User updated', data) | ||||
|         }) | ||||
|         .catch((error) => { | ||||
|           console.error('Failed to hide series from home', error) | ||||
|           console.error('Failed to hide item from home', error) | ||||
|           this.$toast.error('Failed to update user') | ||||
|         }) | ||||
|         .finally(() => { | ||||
|  | ||||
| @ -13,7 +13,22 @@ | ||||
|     <div ref="slider" class="w-full overflow-y-hidden overflow-x-auto no-scroll -mx-2" style="scroll-behavior: smooth" @scroll="scrolled"> | ||||
|       <div class="flex" :style="{ height: height + 'px' }"> | ||||
|         <template v-for="(item, index) in items"> | ||||
|           <cards-lazy-book-card :key="item.recentEpisode.id" :ref="`slider-episode-${item.recentEpisode.id}`" :index="index" :book-mount="item" :height="cardHeight" :width="cardWidth" :book-cover-aspect-ratio="bookCoverAspectRatio" :bookshelf-view="bookshelfView" class="relative mx-2" @edit="editEpisode" @editPodcast="editPodcast" @select="selectItem" @hook:updated="setScrollVars" /> | ||||
|           <cards-lazy-book-card | ||||
|             :key="item.recentEpisode.id" | ||||
|             :ref="`slider-episode-${item.recentEpisode.id}`" | ||||
|             :index="index" | ||||
|             :book-mount="item" | ||||
|             :height="cardHeight" | ||||
|             :width="cardWidth" | ||||
|             :book-cover-aspect-ratio="bookCoverAspectRatio" | ||||
|             :bookshelf-view="bookshelfView" | ||||
|             :continue-listening-shelf="continueListeningShelf" | ||||
|             class="relative mx-2" | ||||
|             @edit="editEpisode" | ||||
|             @editPodcast="editPodcast" | ||||
|             @select="selectItem" | ||||
|             @hook:updated="setScrollVars" | ||||
|           /> | ||||
|         </template> | ||||
|       </div> | ||||
|     </div> | ||||
| @ -34,7 +49,8 @@ export default { | ||||
|     bookshelfView: { | ||||
|       type: Number, | ||||
|       default: 1 | ||||
|     } | ||||
|     }, | ||||
|     continueListeningShelf: Boolean | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|  | ||||
| @ -378,7 +378,7 @@ module.exports = { | ||||
|                 } | ||||
|                 categoryMap.recentlyFinished.biggest = categoryMap.recentlyFinished.items[0].finishedAt | ||||
|               } | ||||
|             } else if (mediaProgress.progress > 0) { // Handle most recently listened
 | ||||
|             } else if (mediaProgress.inProgress && !mediaProgress.hideFromContinueListening) { // Handle most recently listened
 | ||||
|               if (mediaProgress.lastUpdate > categoryMap.recentlyListened.smallest) { // Item belongs on shelf
 | ||||
|                 const libraryItemWithEpisode = { | ||||
|                   ...libraryItem.toJSONMinified(), | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user