mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 23:25:56 -05:00
Fix for byRating function
This commit is contained in:
parent
41d80c4f1a
commit
21173d6480
@ -31,7 +31,6 @@ export function byName(field, defaultValue = '_') {
|
||||
compareFn: (a, b) => {
|
||||
const fieldA = a[field] || defaultValue
|
||||
const fieldB = b[field] || defaultValue
|
||||
|
||||
return fieldA.localeCompare(fieldB, locale.value)
|
||||
},
|
||||
|
||||
@ -47,7 +46,7 @@ export function byRating(field, { direction = 'asc', defaultValue = 0 }) {
|
||||
compareFn: (a, b) => {
|
||||
const fieldA = a[field] || defaultValue
|
||||
const fieldB = b[field] || defaultValue
|
||||
const result = fieldA > fieldB
|
||||
const result = fieldA - fieldB
|
||||
return direction === 'asc' ? result : result * -1
|
||||
},
|
||||
|
||||
@ -63,7 +62,6 @@ export function byYear(field, { direction = 'asc', defaultValue = '0000' }) {
|
||||
compareFn: (a, b) => {
|
||||
const fieldA = a[field] || defaultValue
|
||||
const fieldB = b[field] || defaultValue
|
||||
|
||||
const result = fieldA.localeCompare(fieldB, locale.value)
|
||||
return direction === 'asc' ? result : result * -1
|
||||
},
|
||||
@ -80,19 +78,15 @@ export function byDateSinceToday(field, defaultValue = '0000') {
|
||||
compareFn: (a, b) => {
|
||||
const fieldA = a[field] || defaultValue
|
||||
const fieldB = b[field] || defaultValue
|
||||
|
||||
return fieldB.localeCompare(fieldA, locale.value)
|
||||
},
|
||||
|
||||
groupKeyFn: (item) => {
|
||||
const fieldValue = item[field]
|
||||
|
||||
if (!fieldValue) {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
const diff = new Date().getTime() - new Date(fieldValue).getTime()
|
||||
|
||||
if (diff < 86400000) {
|
||||
// 24h
|
||||
return t('group-by-list.today')
|
||||
@ -159,14 +153,6 @@ export class GroupByList {
|
||||
|
||||
return {
|
||||
next: () => {
|
||||
/*
|
||||
console.log(
|
||||
'[group-by-list] itemIndex=' +
|
||||
itemIndex +
|
||||
', groupIndex=' +
|
||||
groupIndex
|
||||
)
|
||||
*/
|
||||
if (this.isEmpty()) {
|
||||
return { done: true }
|
||||
} else if (groupIndex >= this.indexList.length) {
|
||||
@ -175,11 +161,6 @@ export class GroupByList {
|
||||
// This should never happen, as the we already
|
||||
// return "done" after we reached the last item
|
||||
// of the last group
|
||||
/*
|
||||
console.log(
|
||||
'[group-by-list] done! (groupIndex >= this.indexList.length)'
|
||||
)
|
||||
*/
|
||||
return { done: true }
|
||||
} else if (groupIndex < 0) {
|
||||
// We start iterating
|
||||
@ -240,11 +221,6 @@ export class GroupByList {
|
||||
}
|
||||
} else {
|
||||
// No group left, we are done iterating
|
||||
/*
|
||||
console.log(
|
||||
'[group-by-list] done! (groupIndex >= this.indexList.length)'
|
||||
)
|
||||
*/
|
||||
return { done: true }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user