mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-07 11:44:45 +02:00
Fix:Size and duration sort
This commit is contained in:
parent
95ab2ab4b5
commit
9423727f89
4 changed files with 17 additions and 11 deletions
|
@ -135,12 +135,18 @@ class LibraryController {
|
|||
if (payload.sortBy) {
|
||||
var orderByNumber = payload.sortBy === 'book.volumeNumber'
|
||||
var direction = payload.sortDesc ? 'desc' : 'asc'
|
||||
// if (req.query.sort === 'size') {
|
||||
// console.warn('1SORTING BY SIZE', audiobooks[0])
|
||||
// }
|
||||
audiobooks = sort(audiobooks)[direction]((ab) => {
|
||||
// Supports dot notation strings i.e. "book.title"
|
||||
var value = payload.sortBy.split('.').reduce((a, b) => a[b], ab)
|
||||
if (orderByNumber && !isNaN(value)) return Number(value)
|
||||
return value
|
||||
})
|
||||
// if (req.query.sort === 'size') {
|
||||
// console.warn('2SORTING BY SIZE', audiobooks[0])
|
||||
// }
|
||||
}
|
||||
|
||||
if (payload.limit) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue