YesPlayMusic/packages/web/api/hooks/useUserArtists.ts

16 lines
570 B
TypeScript
Raw Normal View History

2022-05-12 02:45:43 +08:00
import { fetchUserArtists } from '@/web/api/user'
2022-04-16 21:14:03 +08:00
import { UserApiNames, FetchUserArtistsResponse } from '@/shared/api/User'
import { APIs } from '@/shared/CacheAPIs'
import { IpcChannels } from '@/shared/IpcChannels'
2022-05-12 02:45:43 +08:00
import { useQuery } from 'react-query'
export default function useUserArtists() {
return useQuery([UserApiNames.FetchUserArtist], fetchUserArtists, {
refetchOnWindowFocus: true,
placeholderData: (): FetchUserArtistsResponse =>
2022-04-09 00:28:37 +08:00
window.ipcRenderer?.sendSync(IpcChannels.GetApiCacheSync, {
2022-04-16 21:14:03 +08:00
api: APIs.UserArtists,
}),
})
}