mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-06-06 18:52:43 +02:00
Add support for hide from continue listening on new home page shelves route
This commit is contained in:
@@ -49,7 +49,7 @@ module.exports = {
|
||||
*/
|
||||
async getMediaItemsInProgress(library, user, include, limit) {
|
||||
if (library.mediaType === 'book') {
|
||||
const { libraryItems, count } = await libraryItemsBookFilters.getFilteredLibraryItems(library.id, user, 'progress', 'in-progress', 'progress', true, false, include, limit, 0)
|
||||
const { libraryItems, count } = await libraryItemsBookFilters.getFilteredLibraryItems(library.id, user, 'progress', 'in-progress', 'progress', true, false, include, limit, 0, true)
|
||||
return {
|
||||
items: libraryItems.map(li => {
|
||||
const oldLibraryItem = Database.libraryItemModel.getOldLibraryItem(li).toJSONMinified()
|
||||
@@ -61,7 +61,7 @@ module.exports = {
|
||||
count
|
||||
}
|
||||
} else {
|
||||
const { libraryItems, count } = await libraryItemsPodcastFilters.getFilteredPodcastEpisodes(library.id, user, 'progress', 'in-progress', 'progress', true, limit, 0)
|
||||
const { libraryItems, count } = await libraryItemsPodcastFilters.getFilteredPodcastEpisodes(library.id, user, 'progress', 'in-progress', 'progress', true, limit, 0, true)
|
||||
return {
|
||||
count,
|
||||
items: libraryItems.map(li => {
|
||||
|
||||
@@ -337,9 +337,10 @@ module.exports = {
|
||||
* @param {string[]} include
|
||||
* @param {number} limit
|
||||
* @param {number} offset
|
||||
* @param {boolean} isHomePage for home page shelves
|
||||
* @returns {object} { libraryItems:LibraryItem[], count:number }
|
||||
*/
|
||||
async getFilteredLibraryItems(libraryId, user, filterGroup, filterValue, sortBy, sortDesc, collapseseries, include, limit, offset) {
|
||||
async getFilteredLibraryItems(libraryId, user, filterGroup, filterValue, sortBy, sortDesc, collapseseries, include, limit, offset, isHomePage = false) {
|
||||
// TODO: Handle collapse sub-series
|
||||
if (filterGroup === 'series' && collapseseries) {
|
||||
collapseseries = false
|
||||
@@ -471,12 +472,17 @@ module.exports = {
|
||||
}
|
||||
]
|
||||
} else if (filterGroup === 'progress' && user) {
|
||||
const mediaProgressWhere = {
|
||||
userId: user.id
|
||||
}
|
||||
// Respect hide from continue listening for home page shelf
|
||||
if (isHomePage) {
|
||||
mediaProgressWhere.hideFromContinueListening = false
|
||||
}
|
||||
bookIncludes.push({
|
||||
model: Database.mediaProgressModel,
|
||||
attributes: ['id', 'isFinished', 'currentTime', 'ebookProgress', 'updatedAt'],
|
||||
where: {
|
||||
userId: user.id
|
||||
},
|
||||
where: mediaProgressWhere,
|
||||
required: false
|
||||
})
|
||||
} else if (filterGroup === 'recent') {
|
||||
|
||||
@@ -204,9 +204,10 @@ module.exports = {
|
||||
* @param {string} sortDesc
|
||||
* @param {number} limit
|
||||
* @param {number} offset
|
||||
* @param {boolean} isHomePage for home page shelves
|
||||
* @returns {object} {libraryItems:LibraryItem[], count:number}
|
||||
*/
|
||||
async getFilteredPodcastEpisodes(libraryId, user, filterGroup, filterValue, sortBy, sortDesc, limit, offset) {
|
||||
async getFilteredPodcastEpisodes(libraryId, user, filterGroup, filterValue, sortBy, sortDesc, limit, offset, isHomePage = false) {
|
||||
if (sortBy === 'progress' && filterGroup !== 'progress') {
|
||||
Logger.warn('Cannot sort podcast episodes by progress without filtering by progress')
|
||||
sortBy = 'createdAt'
|
||||
@@ -218,11 +219,16 @@ module.exports = {
|
||||
libraryId
|
||||
}
|
||||
if (filterGroup === 'progress') {
|
||||
const mediaProgressWhere = {
|
||||
userId: user.id
|
||||
}
|
||||
// Respect hide from continue listening for home page shelf
|
||||
if (isHomePage) {
|
||||
mediaProgressWhere.hideFromContinueListening = false
|
||||
}
|
||||
podcastEpisodeIncludes.push({
|
||||
model: Database.mediaProgressModel,
|
||||
where: {
|
||||
userId: user.id
|
||||
},
|
||||
where: mediaProgressWhere,
|
||||
attributes: ['id', 'isFinished', 'currentTime', 'updatedAt']
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user