mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 18:13:31 +00:00
minor artist count fixes
This commit is contained in:
parent
f03d88cd8c
commit
781d8055b5
6 changed files with 47 additions and 18 deletions
|
|
@ -278,11 +278,25 @@ const normalizeAlbumArtist = (
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let albumCount: number;
|
||||||
|
let songCount: number;
|
||||||
|
|
||||||
|
if (item.stats) {
|
||||||
|
albumCount = Math.max(
|
||||||
|
item.stats.albumartist?.albumCount ?? 0,
|
||||||
|
item.stats.artist?.albumCount ?? 0,
|
||||||
|
);
|
||||||
|
songCount = Math.max(
|
||||||
|
item.stats.albumartist?.songCount ?? 0,
|
||||||
|
item.stats.artist?.songCount ?? 0,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
albumCount = item.albumCount;
|
||||||
|
songCount = item.songCount;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
albumCount: Math.max(
|
albumCount,
|
||||||
item.stats?.albumartist?.albumCount || item.albumCount,
|
|
||||||
item.stats?.artist?.albumCount || 0,
|
|
||||||
),
|
|
||||||
backgroundImageUrl: null,
|
backgroundImageUrl: null,
|
||||||
biography: item.biography || null,
|
biography: item.biography || null,
|
||||||
duration: null,
|
duration: null,
|
||||||
|
|
@ -307,7 +321,7 @@ const normalizeAlbumArtist = (
|
||||||
imageUrl: artist?.artistImageUrl || null,
|
imageUrl: artist?.artistImageUrl || null,
|
||||||
name: artist.name,
|
name: artist.name,
|
||||||
})) || null,
|
})) || null,
|
||||||
songCount: item.stats?.albumartist?.songCount || item.songCount,
|
songCount,
|
||||||
userFavorite: item.starred,
|
userFavorite: item.starred,
|
||||||
userRating: item.rating,
|
userRating: item.rating,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ export const SubsonicController: ControllerEndpoint = {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...ssNormalize.albumArtist(artist, apiClientProps.server, 300),
|
...ssNormalize.albumArtist(artist, apiClientProps.server, 300),
|
||||||
albums: artist.album.map((album) => ssNormalize.album(album, apiClientProps.server)),
|
albums: artist.album?.map((album) => ssNormalize.album(album, apiClientProps.server)),
|
||||||
similarArtists:
|
similarArtists:
|
||||||
artistInfo?.similarArtist?.map((artist) =>
|
artistInfo?.similarArtist?.map((artist) =>
|
||||||
ssNormalize.albumArtist(artist, apiClientProps.server, 300),
|
ssNormalize.albumArtist(artist, apiClientProps.server, 300),
|
||||||
|
|
@ -305,7 +305,7 @@ export const SubsonicController: ControllerEndpoint = {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return artist.body.artist.album;
|
return artist.body.artist.album ?? [];
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -966,7 +966,7 @@ export const SubsonicController: ControllerEndpoint = {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return artist.body.artist.album;
|
return artist.body.artist.album ?? [];
|
||||||
});
|
});
|
||||||
|
|
||||||
const albumIds = albums.map((album) => album.id);
|
const albumIds = albums.map((album) => album.id);
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ const albumListParameters = z.object({
|
||||||
const albumList = z.array(album.omit({ song: true }));
|
const albumList = z.array(album.omit({ song: true }));
|
||||||
|
|
||||||
const albumArtist = z.object({
|
const albumArtist = z.object({
|
||||||
album: z.array(album),
|
album: z.array(album).optional(),
|
||||||
albumCount: z.string(),
|
albumCount: z.string(),
|
||||||
artistImageUrl: z.string().optional(),
|
artistImageUrl: z.string().optional(),
|
||||||
coverArt: z.string().optional(),
|
coverArt: z.string().optional(),
|
||||||
|
|
|
||||||
|
|
@ -28,25 +28,29 @@ export const AlbumArtistDetailHeader = forwardRef(
|
||||||
serverId: server?.id,
|
serverId: server?.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const albumCount = detailQuery?.data?.albumCount;
|
||||||
|
const songCount = detailQuery?.data?.songCount;
|
||||||
|
const duration = detailQuery?.data?.duration;
|
||||||
|
const durationEnabled = duration !== null && duration !== undefined;
|
||||||
|
|
||||||
const metadataItems = [
|
const metadataItems = [
|
||||||
{
|
{
|
||||||
enabled: detailQuery?.data?.albumCount,
|
enabled: albumCount !== null && albumCount !== undefined,
|
||||||
id: 'albumCount',
|
id: 'albumCount',
|
||||||
secondary: false,
|
secondary: false,
|
||||||
value: t('entity.albumWithCount', { count: detailQuery?.data?.albumCount || 0 }),
|
value: t('entity.albumWithCount', { count: albumCount || 0 }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: detailQuery?.data?.songCount,
|
enabled: songCount !== null && songCount !== undefined,
|
||||||
id: 'songCount',
|
id: 'songCount',
|
||||||
secondary: false,
|
secondary: false,
|
||||||
value: t('entity.trackWithCount', { count: detailQuery?.data?.songCount || 0 }),
|
value: t('entity.trackWithCount', { count: songCount || 0 }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
enabled: detailQuery.data?.duration,
|
enabled: durationEnabled,
|
||||||
id: 'duration',
|
id: 'duration',
|
||||||
secondary: true,
|
secondary: true,
|
||||||
value:
|
value: durationEnabled && formatDurationString(duration),
|
||||||
detailQuery?.data?.duration && formatDurationString(detailQuery.data.duration),
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
import { useCallback, useState, Fragment, useRef } from 'react';
|
import { useCallback, useState, Fragment, useRef } from 'react';
|
||||||
import { ActionIcon, Group, Kbd, ScrollArea } from '@mantine/core';
|
import { ActionIcon, Group, Kbd, ScrollArea } from '@mantine/core';
|
||||||
import { useDisclosure, useDebouncedValue } from '@mantine/hooks';
|
import { useDisclosure, useDebouncedValue } from '@mantine/hooks';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { RiSearchLine, RiCloseFill } from 'react-icons/ri';
|
import { RiSearchLine, RiCloseFill } from 'react-icons/ri';
|
||||||
import { generatePath, useNavigate } from 'react-router';
|
import { generatePath, useNavigate } from 'react-router';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
@ -37,6 +38,7 @@ export const CommandPalette = ({ modalProps }: CommandPaletteProps) => {
|
||||||
const activePage = pages[pages.length - 1];
|
const activePage = pages[pages.length - 1];
|
||||||
const isHome = activePage === CommandPalettePages.HOME;
|
const isHome = activePage === CommandPalettePages.HOME;
|
||||||
const searchInputRef = useRef<HTMLInputElement>(null);
|
const searchInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const popPage = useCallback(() => {
|
const popPage = useCallback(() => {
|
||||||
setPages((pages) => {
|
setPages((pages) => {
|
||||||
|
|
@ -187,13 +189,17 @@ export const CommandPalette = ({ modalProps }: CommandPaletteProps) => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<LibraryCommandItem
|
<LibraryCommandItem
|
||||||
|
disabled={artist?.albumCount === 0}
|
||||||
handlePlayQueueAdd={handlePlayQueueAdd}
|
handlePlayQueueAdd={handlePlayQueueAdd}
|
||||||
id={artist.id}
|
id={artist.id}
|
||||||
imageUrl={artist.imageUrl}
|
imageUrl={artist.imageUrl}
|
||||||
itemType={LibraryItem.ALBUM_ARTIST}
|
itemType={LibraryItem.ALBUM_ARTIST}
|
||||||
subtitle={
|
subtitle={
|
||||||
(artist?.albumCount || 0) > 0
|
artist?.albumCount !== undefined &&
|
||||||
? `${artist.albumCount} albums`
|
artist?.albumCount !== null
|
||||||
|
? t('entity.albumWithCount', {
|
||||||
|
count: artist.albumCount,
|
||||||
|
})
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
title={artist.name}
|
title={artist.name}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ const StyledImage = styled.img`
|
||||||
const ActionsContainer = styled(Flex)``;
|
const ActionsContainer = styled(Flex)``;
|
||||||
|
|
||||||
interface LibraryCommandItemProps {
|
interface LibraryCommandItemProps {
|
||||||
|
disabled?: boolean;
|
||||||
handlePlayQueueAdd?: (options: PlayQueueAddOptions) => void;
|
handlePlayQueueAdd?: (options: PlayQueueAddOptions) => void;
|
||||||
id: string;
|
id: string;
|
||||||
imageUrl: string | null;
|
imageUrl: string | null;
|
||||||
|
|
@ -62,6 +63,7 @@ interface LibraryCommandItemProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LibraryCommandItem = ({
|
export const LibraryCommandItem = ({
|
||||||
|
disabled,
|
||||||
id,
|
id,
|
||||||
imageUrl,
|
imageUrl,
|
||||||
subtitle,
|
subtitle,
|
||||||
|
|
@ -154,6 +156,7 @@ export const LibraryCommandItem = ({
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
compact
|
compact
|
||||||
|
disabled={disabled}
|
||||||
size="md"
|
size="md"
|
||||||
tooltip={{
|
tooltip={{
|
||||||
label: t('player.play', { postProcess: 'sentenceCase' }),
|
label: t('player.play', { postProcess: 'sentenceCase' }),
|
||||||
|
|
@ -166,6 +169,7 @@ export const LibraryCommandItem = ({
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
compact
|
compact
|
||||||
|
disabled={disabled}
|
||||||
size="md"
|
size="md"
|
||||||
tooltip={{
|
tooltip={{
|
||||||
label: t('player.addLast', { postProcess: 'sentenceCase' }),
|
label: t('player.addLast', { postProcess: 'sentenceCase' }),
|
||||||
|
|
@ -179,6 +183,7 @@ export const LibraryCommandItem = ({
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
compact
|
compact
|
||||||
|
disabled={disabled}
|
||||||
size="md"
|
size="md"
|
||||||
tooltip={{
|
tooltip={{
|
||||||
label: t('player.addNext', { postProcess: 'sentenceCase' }),
|
label: t('player.addNext', { postProcess: 'sentenceCase' }),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue