Fix crash on get recent series home page shelf endpoint

This commit is contained in:
advplyr 2023-09-05 16:10:46 -05:00
parent adccccbd7a
commit a44ee913c4

View File

@ -265,12 +265,17 @@ module.exports = {
}) })
}) })
oldSeries.books = s.bookSeries.map(bs => { oldSeries.books = s.bookSeries.map(bs => {
const libraryItem = bs.book.libraryItem.toJSON() const libraryItem = bs.book.libraryItem?.toJSON()
if (!libraryItem) {
Logger.warn(`Book series book has no libraryItem`, bs, bs.book, 'series=', series)
return null
}
delete bs.book.libraryItem delete bs.book.libraryItem
libraryItem.media = bs.book libraryItem.media = bs.book
const oldLibraryItem = Database.libraryItemModel.getOldLibraryItem(libraryItem).toJSONMinified() const oldLibraryItem = Database.libraryItemModel.getOldLibraryItem(libraryItem).toJSONMinified()
return oldLibraryItem return oldLibraryItem
}) }).filter(b => b)
allOldSeries.push(oldSeries) allOldSeries.push(oldSeries)
} }