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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 131 additions and 10 deletions

View file

@ -58,6 +58,10 @@ export const AlbumListGridView = ({ gridRef, itemCount }: any) => {
rows.push(ALBUM_CARD_ROWS.albumArtists);
rows.push(ALBUM_CARD_ROWS.duration);
break;
case AlbumListSort.EXPLICIT_STATUS:
rows.push(ALBUM_CARD_ROWS.albumArtists);
rows.push(ALBUM_CARD_ROWS.explicitStatus);
break;
case AlbumListSort.FAVORITED:
rows.push(ALBUM_CARD_ROWS.albumArtists);
rows.push(ALBUM_CARD_ROWS.releaseYear);

View file

@ -102,6 +102,11 @@ const FILTERS = {
name: i18n.t('filter.duration', { postProcess: 'titleCase' }),
value: AlbumListSort.DURATION,
},
{
defaultOrder: SortOrder.DESC,
name: i18n.t('filter.explicitStatus', { postProcess: 'titleCase' }),
value: AlbumListSort.EXPLICIT_STATUS,
},
{
defaultOrder: SortOrder.DESC,
name: i18n.t('filter.mostPlayed', { postProcess: 'titleCase' }),

View file

@ -16,6 +16,7 @@ import { Separator } from '/@/shared/components/separator/separator';
import { Spoiler } from '/@/shared/components/spoiler/spoiler';
import { Table } from '/@/shared/components/table/table';
import { Text } from '/@/shared/components/text/text';
import { ExplicitStatus } from '/@/shared/types/domain-types';
import {
Album,
AlbumArtist,
@ -34,14 +35,14 @@ type ItemDetailRow<T> = {
key?: keyof T;
label: string;
postprocess?: string[];
render?: (item: T) => ReactNode;
render?: (item: T, t: TFunction) => ReactNode;
};
const handleRow = <T extends AnyLibraryItem>(t: TFunction, item: T, rule: ItemDetailRow<T>) => {
let value: ReactNode;
if (rule.render) {
value = rule.render(item);
value = rule.render(item, t);
} else {
const prop = item[rule.key!];
value = prop !== undefined && prop !== null ? String(prop) : null;
@ -128,6 +129,15 @@ const AlbumPropertyMapping: ItemDetailRow<Album>[] = [
},
{ key: 'releaseYear', label: 'filter.releaseYear' },
{ key: 'songCount', label: 'filter.songCount' },
{
label: 'filter.explicitStatus',
render: (album, t) =>
album.explicitStatus === ExplicitStatus.EXPLICIT
? t('common.explicit', { postProcess: 'sentenceCase' })
: album.explicitStatus === ExplicitStatus.CLEAN
? t('common.clean', { postProcess: 'sentenceCase' })
: null,
},
{ label: 'filter.isCompilation', render: (album) => BoolField(album.isCompilation || false) },
{
key: 'size',
@ -266,6 +276,15 @@ const SongPropertyMapping: ItemDetailRow<Song>[] = [
{ key: 'discNumber', label: 'common.disc' },
{ key: 'trackNumber', label: 'common.trackNumber' },
{ key: 'releaseYear', label: 'filter.releaseYear' },
{
label: 'filter.explicitStatus',
render: (song, t) =>
song.explicitStatus === ExplicitStatus.EXPLICIT
? t('common.explicit', { postProcess: 'sentenceCase' })
: song.explicitStatus === ExplicitStatus.CLEAN
? t('common.clean', { postProcess: 'sentenceCase' })
: null,
},
{ label: 'entity.genre_other', render: FormatGenre },
{
label: 'common.duration',

View file

@ -85,6 +85,9 @@ export const SongListGridView = ({ gridRef, itemCount }: SongListGridViewProps)
case SongListSort.DURATION:
rows.push(SONG_CARD_ROWS.duration);
break;
case SongListSort.EXPLICIT_STATUS:
rows.push(SONG_CARD_ROWS.explicitStatus);
break;
case SongListSort.FAVORITED:
break;
case SongListSort.NAME:

View file

@ -133,6 +133,11 @@ const FILTERS = {
name: i18n.t('filter.duration', { postProcess: 'titleCase' }),
value: SongListSort.DURATION,
},
{
defaultOrder: SortOrder.DESC,
name: i18n.t('filter.explicitStatus', { postProcess: 'titleCase' }),
value: SongListSort.EXPLICIT_STATUS,
},
{
defaultOrder: SortOrder.DESC,
name: i18n.t('filter.isFavorited', { postProcess: 'titleCase' }),