feat: Add explicit status for Navidrome and OpenSubsonic (#1220)

* add navidrome explicit status

* add ExplicitStatus enum and support opensubsonic

* add explicit status to cards
This commit is contained in:
Lyall
2025-10-26 13:48:45 +00:00
committed by GitHub
parent 68f242d208
commit 4dd52b0cef
16 changed files with 131 additions and 10 deletions
+35 -5
View File
@@ -1,6 +1,7 @@
import clsx from 'clsx';
import formatDuration from 'format-duration';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { generatePath } from 'react-router';
import { Link } from 'react-router-dom';
@@ -9,7 +10,14 @@ import styles from './card-rows.module.css';
import { AppRoute } from '/@/renderer/router/routes';
import { formatDateAbsolute, formatDateRelative, formatRating } from '/@/renderer/utils/format';
import { Text } from '/@/shared/components/text/text';
import { Album, AlbumArtist, Artist, Playlist, Song } from '/@/shared/types/domain-types';
import {
Album,
AlbumArtist,
Artist,
ExplicitStatus,
Playlist,
Song,
} from '/@/shared/types/domain-types';
import { CardRow } from '/@/shared/types/types';
interface CardRowsProps {
@@ -18,6 +26,8 @@ interface CardRowsProps {
}
export const CardRows = ({ data, rows }: CardRowsProps) => {
const { t } = useTranslation();
return (
<>
{rows.map((row, index: number) => {
@@ -66,7 +76,7 @@ export const CardRows = ({ data, rows }: CardRowsProps) => {
>
{row.arrayProperty &&
(row.format
? row.format(item)
? row.format(item, t)
: item[row.arrayProperty])}
</Text>
</React.Fragment>
@@ -92,7 +102,9 @@ export const CardRows = ({ data, rows }: CardRowsProps) => {
size={index > 0 ? 'sm' : 'md'}
>
{row.arrayProperty &&
(row.format ? row.format(item) : item[row.arrayProperty])}
(row.format
? row.format(item, t)
: item[row.arrayProperty])}
</Text>
))}
</div>
@@ -123,7 +135,7 @@ export const CardRows = ({ data, rows }: CardRowsProps) => {
}, {}),
)}
>
{data && (row.format ? row.format(data) : data[row.property])}
{data && (row.format ? row.format(data, t) : data[row.property])}
</Text>
) : (
<Text
@@ -132,7 +144,7 @@ export const CardRows = ({ data, rows }: CardRowsProps) => {
overflow="hidden"
size={index > 0 ? 'sm' : 'md'}
>
{data && (row.format ? row.format(data) : data[row.property])}
{data && (row.format ? row.format(data, t) : data[row.property])}
</Text>
)}
</div>
@@ -167,6 +179,15 @@ export const ALBUM_CARD_ROWS: { [key: string]: CardRow<Album> } = {
format: (album) => (album.duration === null ? null : formatDuration(album.duration)),
property: 'duration',
},
explicitStatus: {
format: (album, t) =>
album.explicitStatus === ExplicitStatus.EXPLICIT
? t('common.explicit', { postProcess: 'sentenceCase' })
: album.explicitStatus === ExplicitStatus.CLEAN
? t('common.clean', { postProcess: 'sentenceCase' })
: null,
property: 'explicitStatus',
},
lastPlayedAt: {
format: (album) => formatDateRelative(album.lastPlayedAt),
property: 'lastPlayedAt',
@@ -228,6 +249,15 @@ export const SONG_CARD_ROWS: { [key: string]: CardRow<Song> } = {
format: (song) => (song.duration === null ? null : formatDuration(song.duration)),
property: 'duration',
},
explicitStatus: {
format: (song, t) =>
song.explicitStatus === ExplicitStatus.EXPLICIT
? t('common.explicit', { postProcess: 'sentenceCase' })
: song.explicitStatus === ExplicitStatus.CLEAN
? t('common.clean', { postProcess: 'sentenceCase' })
: null,
property: 'explicitStatus',
},
lastPlayedAt: {
format: (song) => formatDateRelative(song.lastPlayedAt),
property: 'lastPlayedAt',