3294bcacfc
* feat(model): add Rated At field - #4653 Signed-off-by: zacaj <zacaj@zacaj.com> * fix(ui): ignore empty dates in rating/love tooltips - #4653 * refactor(ui): add isDateSet util function Signed-off-by: zacaj <zacaj@zacaj.com> * feat: add tests for isDateSet and rated_at sort mappings Added comprehensive tests for isDateSet and urlValidate functions in ui/src/utils/validations.test.js covering falsy values, Go zero date handling, valid date strings, Date objects, and edge cases. Added rated_at sort mapping to album, artist, and mediafile repositories, following the same pattern as starred_at (sorting by rating first, then by timestamp). This enables proper sorting by rating date in the UI. --------- Signed-off-by: zacaj <zacaj@zacaj.com> Co-authored-by: zacaj <zacaj@zacaj.com> Co-authored-by: Deluan <deluan@navidrome.org>
26 lines
444 B
JavaScript
26 lines
444 B
JavaScript
export const urlValidate = (value) => {
|
|
if (!value) {
|
|
return undefined
|
|
}
|
|
|
|
try {
|
|
new URL(value)
|
|
return undefined
|
|
} catch (_) {
|
|
return 'ra.validation.url'
|
|
}
|
|
}
|
|
|
|
export function isDateSet(date) {
|
|
if (!date) {
|
|
return false
|
|
}
|
|
if (typeof date === 'string') {
|
|
return date !== '0001-01-01T00:00:00Z'
|
|
}
|
|
if (date instanceof Date) {
|
|
return date.toISOString() !== '0001-01-01T00:00:00Z'
|
|
}
|
|
return !!date
|
|
}
|