mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-14 04:20:07 +02:00
ba531505af
* [enhancement]: Support toggling Album/Track view for gneres The _primary_ purpose of this PR is to enable viewing tracks OR albums for genres. This has a few requirements: 1. Ability to set default route for genres, **except** when already on song/album page 2. Ability to toggle between album and genre view 3. Fixed refresh for genre ID Additionally, there was some refactoring: - Since the *-list-headers had very similar functions for search, export that as a hook instead * also use hook for album artist * support switching albumartist tracks/albums * remove toggle on song/album list, simplify logic
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import React from 'react';
|
|
import type { ICellRendererParams } from '@ag-grid-community/core';
|
|
import { generatePath, Link } from 'react-router-dom';
|
|
import type { AlbumArtist, Artist } from '/@/renderer/api/types';
|
|
import { Text } from '/@/renderer/components/text';
|
|
import { CellContainer } from '/@/renderer/components/virtual-table/cells/generic-cell';
|
|
import { Separator } from '/@/renderer/components/separator';
|
|
import { useGenreRoute } from '/@/renderer/hooks/use-genre-route';
|
|
|
|
export const GenreCell = ({ value, data }: ICellRendererParams) => {
|
|
const genrePath = useGenreRoute();
|
|
return (
|
|
<CellContainer $position="left">
|
|
<Text
|
|
$secondary
|
|
overflow="hidden"
|
|
size="md"
|
|
>
|
|
{value?.map((item: Artist | AlbumArtist, index: number) => (
|
|
<React.Fragment key={`row-${item.id}-${data.uniqueId}`}>
|
|
{index > 0 && <Separator />}
|
|
<Text
|
|
$link
|
|
$secondary
|
|
component={Link}
|
|
overflow="hidden"
|
|
size="md"
|
|
to={generatePath(genrePath, { genreId: item.id })}
|
|
>
|
|
{item.name || '—'}
|
|
</Text>
|
|
</React.Fragment>
|
|
))}
|
|
</Text>
|
|
</CellContainer>
|
|
);
|
|
};
|