From aaede2752c823ed5a19759ccdfe2888de59a737d Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Fri, 13 Jan 2023 00:50:04 +0100 Subject: [PATCH] Don't list book twice in continue series MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes, a book belongs to more than one series. If you listen to and finish such a book, Audiobookshelf will list the next book in “Continue Series” twice, right next to each other. That is not helpful. This patch fixes the problem by not adding books to the list if they are already in the list. --- server/utils/libraryHelpers.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/utils/libraryHelpers.js b/server/utils/libraryHelpers.js index 49d5264c..41d140f8 100644 --- a/server/utils/libraryHelpers.js +++ b/server/utils/libraryHelpers.js @@ -672,10 +672,12 @@ module.exports = { } const indexToPut = categoryMap.continueSeries.items.findIndex(i => i.prevBookInProgressLastUpdate < bookForContinueSeries.prevBookInProgressLastUpdate) - if (indexToPut >= 0) { - categoryMap.continueSeries.items.splice(indexToPut, 0, bookForContinueSeries) - } else if (categoryMap.continueSeries.items.length < 10) { // Max 10 books - categoryMap.continueSeries.items.push(bookForContinueSeries) + if (!categoryMap.continueSeries.items.find(book => book.id === bookForContinueSeries.id)) { + if (indexToPut >= 0) { + categoryMap.continueSeries.items.splice(indexToPut, 0, bookForContinueSeries) + } else if (categoryMap.continueSeries.items.length < 10) { // Max 10 books + categoryMap.continueSeries.items.push(bookForContinueSeries) + } } } }