mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-17 00:08:55 +01:00
Add:Putting back in the Continue Series shelf on the home page #541
This commit is contained in:
parent
b19442e440
commit
fc8473ed84
@ -78,7 +78,7 @@
|
|||||||
</ui-tooltip>
|
</ui-tooltip>
|
||||||
|
|
||||||
<!-- Series sequence -->
|
<!-- Series sequence -->
|
||||||
<div v-if="seriesSequence && showSequence && !isHovering && !isSelectionMode" class="absolute rounded-lg bg-black bg-opacity-90 box-shadow-md z-10" :style="{ top: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', padding: `${0.1 * sizeMultiplier}rem ${0.25 * sizeMultiplier}rem` }">
|
<div v-if="seriesSequence && !isHovering && !isSelectionMode" class="absolute rounded-lg bg-black bg-opacity-90 box-shadow-md z-10" :style="{ top: 0.375 * sizeMultiplier + 'rem', right: 0.375 * sizeMultiplier + 'rem', padding: `${0.1 * sizeMultiplier}rem ${0.25 * sizeMultiplier}rem` }">
|
||||||
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }">#{{ seriesSequence }}</p>
|
<p :style="{ fontSize: sizeMultiplier * 0.8 + 'rem' }">#{{ seriesSequence }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -110,7 +110,6 @@ export default {
|
|||||||
default: 192
|
default: 192
|
||||||
},
|
},
|
||||||
bookCoverAspectRatio: Number,
|
bookCoverAspectRatio: Number,
|
||||||
showSequence: Boolean,
|
|
||||||
bookshelfView: Number,
|
bookshelfView: Number,
|
||||||
bookMount: {
|
bookMount: {
|
||||||
// Book can be passed as prop or set with setEntity()
|
// Book can be passed as prop or set with setEntity()
|
||||||
@ -176,7 +175,7 @@ export default {
|
|||||||
return this._libraryItem.id
|
return this._libraryItem.id
|
||||||
},
|
},
|
||||||
series() {
|
series() {
|
||||||
// Only included when filtering by series or collapse series
|
// Only included when filtering by series or collapse series or Continue Series shelf on home page
|
||||||
return this.mediaMetadata.series
|
return this.mediaMetadata.series
|
||||||
},
|
},
|
||||||
seriesSequence() {
|
seriesSequence() {
|
||||||
|
@ -54,7 +54,7 @@ export default {
|
|||||||
bookCoverAspectRatio: this.bookCoverAspectRatio,
|
bookCoverAspectRatio: this.bookCoverAspectRatio,
|
||||||
bookshelfView: this.bookshelfView
|
bookshelfView: this.bookshelfView
|
||||||
}
|
}
|
||||||
if (this.entityName === 'series-books') props.showSequence = true
|
|
||||||
if (this.entityName === 'books') {
|
if (this.entityName === 'books') {
|
||||||
props.filterBy = this.filterBy
|
props.filterBy = this.filterBy
|
||||||
props.orderBy = this.orderBy
|
props.orderBy = this.orderBy
|
||||||
|
@ -245,6 +245,13 @@ module.exports = {
|
|||||||
entities: [],
|
entities: [],
|
||||||
category: 'recentlyListened'
|
category: 'recentlyListened'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'continue-series',
|
||||||
|
label: 'Continue Series',
|
||||||
|
type: mediaType,
|
||||||
|
entities: [],
|
||||||
|
category: 'continueSeries'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'recently-added',
|
id: 'recently-added',
|
||||||
label: 'Recently Added',
|
label: 'Recently Added',
|
||||||
@ -282,7 +289,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const categories = ['recentlyListened', 'newestEpisodes', 'newestItems', 'newestSeries', 'recentlyFinished', 'newestAuthors']
|
const categories = ['recentlyListened', 'continueSeries', 'newestEpisodes', 'newestItems', 'newestSeries', 'recentlyFinished', 'newestAuthors']
|
||||||
const categoryMap = {}
|
const categoryMap = {}
|
||||||
categories.forEach((cat) => {
|
categories.forEach((cat) => {
|
||||||
categoryMap[cat] = {
|
categoryMap[cat] = {
|
||||||
@ -398,20 +405,24 @@ module.exports = {
|
|||||||
// Newest series
|
// Newest series
|
||||||
if (libraryItem.media.metadata.series.length) {
|
if (libraryItem.media.metadata.series.length) {
|
||||||
for (const librarySeries of libraryItem.media.metadata.series) {
|
for (const librarySeries of libraryItem.media.metadata.series) {
|
||||||
|
const mediaProgress = allItemProgress.length ? allItemProgress[0] : null
|
||||||
|
const bookInProgress = mediaProgress && mediaProgress.inProgress
|
||||||
|
const libraryItemJson = libraryItem.toJSONMinified()
|
||||||
|
libraryItemJson.seriesSequence = librarySeries.sequence
|
||||||
|
|
||||||
if (!seriesMap[librarySeries.id]) {
|
if (!seriesMap[librarySeries.id]) {
|
||||||
const seriesObj = allSeries.find(se => se.id === librarySeries.id)
|
const seriesObj = allSeries.find(se => se.id === librarySeries.id)
|
||||||
if (seriesObj) {
|
if (seriesObj) {
|
||||||
var series = {
|
var series = {
|
||||||
...seriesObj.toJSON(),
|
...seriesObj.toJSON(),
|
||||||
books: []
|
books: [libraryItemJson],
|
||||||
|
inProgress: bookInProgress,
|
||||||
|
bookInProgressLastUpdate: bookInProgress ? mediaProgress.lastUpdate : null,
|
||||||
|
sequenceInProgress: bookInProgress ? libraryItemJson.seriesSequence : null
|
||||||
}
|
}
|
||||||
|
seriesMap[librarySeries.id] = series
|
||||||
|
|
||||||
if (series.addedAt > categoryMap.newestSeries.smallest) {
|
if (series.addedAt > categoryMap.newestSeries.smallest) {
|
||||||
const libraryItemJson = libraryItem.toJSONMinified()
|
|
||||||
libraryItemJson.seriesSequence = librarySeries.sequence
|
|
||||||
series.books.push(libraryItemJson)
|
|
||||||
|
|
||||||
var indexToPut = categoryMap.newestSeries.items.findIndex(i => series.addedAt > i.addedAt)
|
var indexToPut = categoryMap.newestSeries.items.findIndex(i => series.addedAt > i.addedAt)
|
||||||
if (indexToPut >= 0) {
|
if (indexToPut >= 0) {
|
||||||
categoryMap.newestSeries.items.splice(indexToPut, 0, series)
|
categoryMap.newestSeries.items.splice(indexToPut, 0, series)
|
||||||
@ -426,15 +437,19 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
categoryMap.newestSeries.biggest = categoryMap.newestSeries.items[0].addedAt
|
categoryMap.newestSeries.biggest = categoryMap.newestSeries.items[0].addedAt
|
||||||
|
|
||||||
seriesMap[librarySeries.id] = series
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// series already in map - add book
|
// series already in map - add book
|
||||||
const libraryItemJson = libraryItem.toJSONMinified()
|
|
||||||
libraryItemJson.seriesSequence = librarySeries.sequence
|
|
||||||
seriesMap[librarySeries.id].books.push(libraryItemJson)
|
seriesMap[librarySeries.id].books.push(libraryItemJson)
|
||||||
|
|
||||||
|
if (bookInProgress) { // Update if this series is in progress
|
||||||
|
seriesMap[librarySeries.id].inProgress = true
|
||||||
|
if (!seriesMap[librarySeries.id].sequenceInProgress) {
|
||||||
|
seriesMap[librarySeries.id].sequenceInProgress = librarySeries.sequence
|
||||||
|
seriesMap[librarySeries.id].bookInProgressLastUpdate = mediaProgress.lastUpdate
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -525,6 +540,38 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For Continue Series - Find next book in series for series that are in progress
|
||||||
|
for (const seriesId in seriesMap) {
|
||||||
|
if (seriesMap[seriesId].inProgress) {
|
||||||
|
seriesMap[seriesId].books = naturalSort(seriesMap[seriesId].books).asc(li => li.seriesSequence)
|
||||||
|
|
||||||
|
const nextBookInSeries = seriesMap[seriesId].books.find(li => {
|
||||||
|
if (!seriesMap[seriesId].sequenceInProgress) return true
|
||||||
|
// True if book series sequence is greater than the current book sequence in progress
|
||||||
|
return String(li.seriesSequence).localeCompare(String(seriesMap[seriesId].sequenceInProgress), undefined, { sensitivity: 'base', numeric: true }) > 0
|
||||||
|
})
|
||||||
|
|
||||||
|
if (nextBookInSeries) {
|
||||||
|
const bookForContinueSeries = {
|
||||||
|
...nextBookInSeries,
|
||||||
|
prevBookInProgressLastUpdate: seriesMap[seriesId].bookInProgressLastUpdate
|
||||||
|
}
|
||||||
|
bookForContinueSeries.media.metadata.series = {
|
||||||
|
id: seriesId,
|
||||||
|
name: seriesMap[seriesId].name,
|
||||||
|
sequence: nextBookInSeries.seriesSequence
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Sort series books by sequence
|
// Sort series books by sequence
|
||||||
if (categoryMap.newestSeries.items.length) {
|
if (categoryMap.newestSeries.items.length) {
|
||||||
for (const seriesItem of categoryMap.newestSeries.items) {
|
for (const seriesItem of categoryMap.newestSeries.items) {
|
||||||
|
Loading…
Reference in New Issue
Block a user