mirror of
				https://github.com/advplyr/audiobookshelf.git
				synced 2025-10-27 11:18:14 +01:00 
			
		
		
		
	use the toggle to not show earlier works than the ones already read
This commit is contained in:
		
							parent
							
								
									a814e45150
								
							
						
					
					
						commit
						c83399c7b5
					
				@ -11,6 +11,7 @@ const oldLibrary = require('../objects/Library')
 | 
			
		||||
 * @property {string} autoScanCronExpression
 | 
			
		||||
 * @property {boolean} audiobooksOnly
 | 
			
		||||
 * @property {boolean} hideSingleBookSeries Do not show series that only have 1 book 
 | 
			
		||||
 * @property {boolean} onlyShowLaterBooksInContinueSeries Skip showing books that are earlier than the max sequence read
 | 
			
		||||
 * @property {string[]} metadataPrecedence
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -9,6 +9,7 @@ class LibrarySettings {
 | 
			
		||||
    this.autoScanCronExpression = null
 | 
			
		||||
    this.audiobooksOnly = false
 | 
			
		||||
    this.hideSingleBookSeries = false // Do not show series that only have 1 book
 | 
			
		||||
    this.onlyShowLaterBooksInContinueSeries = false // Skip showing books that are earlier than the max sequence read
 | 
			
		||||
    this.metadataPrecedence = ['folderStructure', 'audioMetatags', 'nfoFile', 'txtFiles', 'opfFile', 'absMetadata']
 | 
			
		||||
    this.podcastSearchRegion = 'us'
 | 
			
		||||
 | 
			
		||||
@ -25,6 +26,7 @@ class LibrarySettings {
 | 
			
		||||
    this.autoScanCronExpression = settings.autoScanCronExpression || null
 | 
			
		||||
    this.audiobooksOnly = !!settings.audiobooksOnly
 | 
			
		||||
    this.hideSingleBookSeries = !!settings.hideSingleBookSeries
 | 
			
		||||
    this.onlyShowLaterBooksInContinueSeries = !!settings.onlyShowLaterBooksInContinueSeries
 | 
			
		||||
    if (settings.metadataPrecedence) {
 | 
			
		||||
      this.metadataPrecedence = [...settings.metadataPrecedence]
 | 
			
		||||
    } else {
 | 
			
		||||
@ -43,6 +45,7 @@ class LibrarySettings {
 | 
			
		||||
      autoScanCronExpression: this.autoScanCronExpression,
 | 
			
		||||
      audiobooksOnly: this.audiobooksOnly,
 | 
			
		||||
      hideSingleBookSeries: this.hideSingleBookSeries,
 | 
			
		||||
      onlyShowLaterBooksInContinueSeries: this.onlyShowLaterBooksInContinueSeries,
 | 
			
		||||
      metadataPrecedence: [...this.metadataPrecedence],
 | 
			
		||||
      podcastSearchRegion: this.podcastSearchRegion
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -676,11 +676,14 @@ module.exports = {
 | 
			
		||||
      ],
 | 
			
		||||
      attributes: {
 | 
			
		||||
        include: [
 | 
			
		||||
          [Sequelize.literal('(SELECT max(mp.updatedAt) FROM bookSeries bs, mediaProgresses mp WHERE mp.mediaItemId = bs.bookId AND mp.userId = :userId AND bs.seriesId = series.id)'), 'recent_progress']
 | 
			
		||||
          [Sequelize.literal('(SELECT max(mp.updatedAt) FROM bookSeries bs, mediaProgresses mp WHERE mp.mediaItemId = bs.bookId AND mp.userId = :userId AND bs.seriesId = series.id)'), 'recent_progress'],
 | 
			
		||||
          [Sequelize.literal('(SELECT CAST(max(bs.sequence) as FLOAT) FROM bookSeries bs, mediaProgresses mp WHERE mp.mediaItemId = bs.bookId AND mp.userId = :userId AND bs.seriesId = series.id)'), 'maxSequence'],
 | 
			
		||||
          [Sequelize.literal('(SELECT json_extract(libraries.settings, "$.onlyShowLaterBooksInContinueSeries") FROM libraries WHERE id = :libraryId)'), 'onlyShowLaterBooksInContinueSeries']
 | 
			
		||||
        ]
 | 
			
		||||
      },
 | 
			
		||||
      replacements: {
 | 
			
		||||
        userId: user.id,
 | 
			
		||||
        libraryId: libraryId,
 | 
			
		||||
        ...userPermissionBookWhere.replacements
 | 
			
		||||
      },
 | 
			
		||||
      include: {
 | 
			
		||||
@ -731,13 +734,26 @@ module.exports = {
 | 
			
		||||
 | 
			
		||||
    const libraryItems = series.map(s => {
 | 
			
		||||
      if (!s.bookSeries.length) return null // this is only possible if user has restricted books in series
 | 
			
		||||
      const libraryItem = s.bookSeries[0].book.libraryItem.toJSON()
 | 
			
		||||
      const book = s.bookSeries[0].book.toJSON()
 | 
			
		||||
 | 
			
		||||
      var bookIndex = 0
 | 
			
		||||
      // if the library setting is toggled, only show later entries in series, otherwise skip
 | 
			
		||||
      if (s.dataValues.onlyShowLaterBooksInContinueSeries === 1) {
 | 
			
		||||
        bookIndex = s.bookSeries.findIndex(function (b) {
 | 
			
		||||
          return parseFloat(b.dataValues.sequence) > s.dataValues.maxSequence
 | 
			
		||||
        })
 | 
			
		||||
        if (bookIndex === -1) {
 | 
			
		||||
          // no later books than maxSequence
 | 
			
		||||
          return null
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      const libraryItem = s.bookSeries[bookIndex].book.libraryItem.toJSON()
 | 
			
		||||
      const book = s.bookSeries[bookIndex].book.toJSON()
 | 
			
		||||
      delete book.libraryItem
 | 
			
		||||
      libraryItem.series = {
 | 
			
		||||
        id: s.id,
 | 
			
		||||
        name: s.name,
 | 
			
		||||
        sequence: s.bookSeries[0].sequence
 | 
			
		||||
        sequence: s.bookSeries[bookIndex].sequence
 | 
			
		||||
      }
 | 
			
		||||
      if (libraryItem.feeds?.length) {
 | 
			
		||||
        libraryItem.rssFeed = libraryItem.feeds[0]
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user