mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-04 21:17:37 +03:00
better?
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
ded5e8f518
commit
19e1bad4c9
1 changed files with 28 additions and 26 deletions
|
@ -144,11 +144,15 @@ const Details = (props) => {
|
||||||
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
|
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
|
||||||
const translate = useTranslate()
|
const translate = useTranslate()
|
||||||
const record = useRecordContext(props)
|
const record = useRecordContext(props)
|
||||||
|
|
||||||
|
// Create an array of detail elements
|
||||||
let details = []
|
let details = []
|
||||||
const addDetail = (obj) => {
|
const addDetail = (obj) => {
|
||||||
const id = details.length
|
const id = details.length
|
||||||
details.push(<span key={`detail-${record.id}-${id}`}>{obj}</span>)
|
details.push(<span key={`detail-${record.id}-${id}`}>{obj}</span>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Calculate date related fields
|
||||||
const yearRange = formatRange(record, 'year')
|
const yearRange = formatRange(record, 'year')
|
||||||
const date = record.date ? formatFullDate(record.date) : yearRange
|
const date = record.date ? formatFullDate(record.date) : yearRange
|
||||||
|
|
||||||
|
@ -160,34 +164,31 @@ const Details = (props) => {
|
||||||
const dateToUse = originalDate || date
|
const dateToUse = originalDate || date
|
||||||
const isOriginalDate = originalDate && dateToUse !== date
|
const isOriginalDate = originalDate && dateToUse !== date
|
||||||
const showDate = dateToUse && dateToUse !== releaseDate
|
const showDate = dateToUse && dateToUse !== releaseDate
|
||||||
showDate &&
|
|
||||||
addDetail(
|
|
||||||
<>
|
|
||||||
{[
|
|
||||||
isXsmall
|
|
||||||
? '♫'
|
|
||||||
: isOriginalDate
|
|
||||||
? translate('resources.album.fields.originalDate')
|
|
||||||
: undefined,
|
|
||||||
dateToUse,
|
|
||||||
].join(' ')}
|
|
||||||
</>,
|
|
||||||
)
|
|
||||||
|
|
||||||
releaseDate &&
|
// Get label for the main date display
|
||||||
addDetail(
|
const getDateLabel = () => {
|
||||||
<>
|
if (isXsmall) return '♫'
|
||||||
{[
|
if (isOriginalDate) return translate('resources.album.fields.originalDate')
|
||||||
!isXsmall
|
return null
|
||||||
? translate('resources.album.fields.releaseDate')
|
}
|
||||||
: showDate
|
|
||||||
? '○'
|
|
||||||
: undefined,
|
|
||||||
releaseDate,
|
|
||||||
].join(' ')}
|
|
||||||
</>,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
// Get label for release date display
|
||||||
|
const getReleaseDateLabel = () => {
|
||||||
|
if (!isXsmall) return translate('resources.album.fields.releaseDate')
|
||||||
|
if (showDate) return '○'
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display dates with appropriate labels
|
||||||
|
if (showDate) {
|
||||||
|
addDetail(<>{[getDateLabel(), dateToUse].filter(Boolean).join(' ')}</>)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (releaseDate) {
|
||||||
|
addDetail(
|
||||||
|
<>{[getReleaseDateLabel(), releaseDate].filter(Boolean).join(' ')}</>,
|
||||||
|
)
|
||||||
|
}
|
||||||
addDetail(
|
addDetail(
|
||||||
<>
|
<>
|
||||||
{record.songCount +
|
{record.songCount +
|
||||||
|
@ -200,6 +201,7 @@ const Details = (props) => {
|
||||||
!isXsmall && addDetail(<DurationField source={'duration'} />)
|
!isXsmall && addDetail(<DurationField source={'duration'} />)
|
||||||
!isXsmall && addDetail(<SizeField source="size" />)
|
!isXsmall && addDetail(<SizeField source="size" />)
|
||||||
|
|
||||||
|
// Return the details rendered with separators
|
||||||
return <>{intersperse(details, ' · ')}</>
|
return <>{intersperse(details, ' · ')}</>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue