mirror of
https://github.com/koel/koel
synced 2024-11-12 23:47:09 +00:00
fix: sort by disc/track not working if only one disc (#1854)
This commit is contained in:
parent
abfa65bfe8
commit
9c5b763267
1 changed files with 16 additions and 3 deletions
|
@ -135,9 +135,22 @@ export const useSongList = (
|
|||
return playables.value
|
||||
}
|
||||
|
||||
return sortField.value
|
||||
? orderBy(fuzzy.search(filterKeywords.value), extendedSortFields.value!, sortOrder.value)
|
||||
: fuzzy.search(filterKeywords.value)
|
||||
const filtered = fuzzy.search(filterKeywords.value)
|
||||
|
||||
if (!sortField.value) {
|
||||
return filtered
|
||||
}
|
||||
|
||||
const sortFields = extendedSortFields.value!
|
||||
|
||||
if (sortFields[0] === 'disc' && sortFields.length > 1 && new Set(filtered.map(p => p.disc ?? null)).size === 1) {
|
||||
// If we're sorting by disc and there's only one disc, we remove disc from the sort fields.
|
||||
// Otherwise, the tracks will be sorted by disc number first, and since there's only one disc,
|
||||
// the track order will remain the same through alternating between asc and desc.
|
||||
sortFields.shift()
|
||||
}
|
||||
|
||||
return orderBy(filtered, sortFields, sortOrder.value)
|
||||
})
|
||||
|
||||
const onPressEnter = async (event: KeyboardEvent) => {
|
||||
|
|
Loading…
Reference in a new issue