mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2025-03-01 06:57:42 +08:00
28 lines
774 B
TypeScript
28 lines
774 B
TypeScript
import { fetchArtist } from '@/web/api/artist'
|
|
import { IpcChannels } from '@/shared/IpcChannels'
|
|
import { APIs } from '@/shared/CacheAPIs'
|
|
import {
|
|
FetchArtistParams,
|
|
ArtistApiNames,
|
|
FetchArtistResponse,
|
|
} from '@/shared/api/Artist'
|
|
import { useQuery } from 'react-query'
|
|
|
|
export default function useArtists(ids: number[]) {
|
|
return useQuery(
|
|
['fetchArtists', ids],
|
|
() => Promise.all(ids.map(id => fetchArtist({ id }, false))),
|
|
{
|
|
enabled: !!ids && ids.length > 0,
|
|
staleTime: 5 * 60 * 1000, // 5 mins
|
|
// placeholderData: (): FetchArtistResponse[] =>
|
|
// window.ipcRenderer?.sendSync(IpcChannels.GetApiCacheSync, {
|
|
// api: APIs.Artist,
|
|
// query: {
|
|
// ids,
|
|
// },
|
|
// }),
|
|
}
|
|
)
|
|
}
|