Don't list book twice in continue series

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.
This commit is contained in:
Lars Kiesow 2023-01-13 00:50:04 +01:00
parent 39d8c2cf04
commit aaede2752c
No known key found for this signature in database
GPG Key ID: 5DAFE8D9C823CE73

View File

@ -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)
}
}
}
}