don't pass song all the way down
This commit is contained in:
parent
c947d09615
commit
f81bea339b
6 changed files with 17 additions and 20 deletions
|
@ -967,7 +967,7 @@ const getSimilarSongs = async (args: SimilarSongsArgs): Promise<Song[]> => {
|
||||||
|
|
||||||
const res = await jfApiClient(apiClientProps).getSimilarSongs({
|
const res = await jfApiClient(apiClientProps).getSimilarSongs({
|
||||||
params: {
|
params: {
|
||||||
itemId: query.song.id,
|
itemId: query.songId,
|
||||||
},
|
},
|
||||||
query: {
|
query: {
|
||||||
Fields: 'Genres, DateCreated, MediaSources, ParentId',
|
Fields: 'Genres, DateCreated, MediaSources, ParentId',
|
||||||
|
|
|
@ -452,7 +452,7 @@ const getSimilarSongs = async (args: SimilarSongsArgs): Promise<Song[]> => {
|
||||||
const res = await ssApiClient(apiClientProps).getSimilarSongs({
|
const res = await ssApiClient(apiClientProps).getSimilarSongs({
|
||||||
query: {
|
query: {
|
||||||
count: query.count,
|
count: query.count,
|
||||||
id: query.song.id,
|
id: query.songId,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1173,7 +1173,7 @@ export type StructuredLyric = {
|
||||||
|
|
||||||
export type SimilarSongsQuery = {
|
export type SimilarSongsQuery = {
|
||||||
count?: number;
|
count?: number;
|
||||||
song: Song;
|
songId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SimilarSongsArgs = {
|
export type SimilarSongsArgs = {
|
||||||
|
|
|
@ -4,10 +4,10 @@ import { useCurrentSong } from '/@/renderer/store';
|
||||||
export const FullScreenSimilarSongs = () => {
|
export const FullScreenSimilarSongs = () => {
|
||||||
const currentSong = useCurrentSong();
|
const currentSong = useCurrentSong();
|
||||||
|
|
||||||
return (
|
return currentSong ? (
|
||||||
<SimilarSongsList
|
<SimilarSongsList
|
||||||
fullScreen
|
fullScreen
|
||||||
song={currentSong}
|
song={currentSong}
|
||||||
/>
|
/>
|
||||||
);
|
) : null;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { useHandlePlayQueueAdd } from '/@/renderer/features/player/hooks/use-han
|
||||||
export type SimilarSongsListProps = {
|
export type SimilarSongsListProps = {
|
||||||
count?: number;
|
count?: number;
|
||||||
fullScreen?: boolean;
|
fullScreen?: boolean;
|
||||||
song?: Song;
|
song: Song;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SimilarSongsList = ({ count, fullScreen, song }: SimilarSongsListProps) => {
|
export const SimilarSongsList = ({ count, fullScreen, song }: SimilarSongsListProps) => {
|
||||||
|
@ -30,8 +30,8 @@ export const SimilarSongsList = ({ count, fullScreen, song }: SimilarSongsListPr
|
||||||
cacheTime: 1000 * 60 * 2,
|
cacheTime: 1000 * 60 * 2,
|
||||||
staleTime: 1000 * 60 * 1,
|
staleTime: 1000 * 60 * 1,
|
||||||
},
|
},
|
||||||
query: { count, song },
|
query: { count, songId: song.id },
|
||||||
serverId: undefined,
|
serverId: song?.serverId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnDefs = useMemo(
|
const columnDefs = useMemo(
|
||||||
|
@ -52,12 +52,10 @@ export const SimilarSongsList = ({ count, fullScreen, song }: SimilarSongsListPr
|
||||||
};
|
};
|
||||||
|
|
||||||
return songQuery.isLoading ? (
|
return songQuery.isLoading ? (
|
||||||
song ? (
|
|
||||||
<Spinner
|
<Spinner
|
||||||
container
|
container
|
||||||
size={25}
|
size={25}
|
||||||
/>
|
/>
|
||||||
) : undefined
|
|
||||||
) : (
|
) : (
|
||||||
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
||||||
<VirtualGridAutoSizerContainer>
|
<VirtualGridAutoSizerContainer>
|
||||||
|
|
|
@ -5,19 +5,18 @@ import { getServerById } from '/@/renderer/store';
|
||||||
import { queryKeys } from '/@/renderer/api/query-keys';
|
import { queryKeys } from '/@/renderer/api/query-keys';
|
||||||
import { api } from '/@/renderer/api';
|
import { api } from '/@/renderer/api';
|
||||||
|
|
||||||
export const useSimilarSongs = (args: QueryHookArgs<Partial<SimilarSongsQuery>>) => {
|
export const useSimilarSongs = (args: QueryHookArgs<SimilarSongsQuery>) => {
|
||||||
const { options, query } = args || {};
|
const { options, query, serverId } = args || {};
|
||||||
const server = getServerById(query.song?.serverId);
|
const server = getServerById(serverId);
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
enabled: !!server?.id && !!query.song,
|
enabled: !!server,
|
||||||
queryFn: ({ signal }) => {
|
queryFn: ({ signal }) => {
|
||||||
if (!server) throw new Error('Server not found');
|
if (!server) throw new Error('Server not found');
|
||||||
if (!query.song) return undefined;
|
|
||||||
|
|
||||||
return api.controller.getSimilarSongs({
|
return api.controller.getSimilarSongs({
|
||||||
apiClientProps: { server, signal },
|
apiClientProps: { server, signal },
|
||||||
query: { count: query.count ?? 50, song: query.song },
|
query: { count: query.count ?? 50, songId: query.songId },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
queryKey: queryKeys.albumArtists.detail(server?.id || '', query),
|
queryKey: queryKeys.albumArtists.detail(server?.id || '', query),
|
||||||
|
|
Reference in a new issue