mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 13:48:02 +00:00
feat: updates
This commit is contained in:
parent
cf7a4528dd
commit
0e58bb6e80
44 changed files with 1027 additions and 496 deletions
27
packages/web/api/hooks/useArtists.ts
Normal file
27
packages/web/api/hooks/useArtists.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
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,
|
||||
// },
|
||||
// }),
|
||||
}
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue