YesPlayMusic/packages/web/hooks/useAppleMusicAlbum.ts
2022-08-03 23:48:39 +08:00

27 lines
619 B
TypeScript

import { IpcChannels } from '@/shared/IpcChannels'
import { useQuery } from '@tanstack/react-query'
export default function useAppleMusicAlbum(props: {
id?: number
name?: string
artist?: string
}) {
const { id, name, artist } = props
return useQuery(
['useAppleMusicAlbum', props],
async () => {
if (!id || !name || !artist) return
return window.ipcRenderer?.invoke(IpcChannels.GetAlbumFromAppleMusic, {
id,
name,
artist,
})
},
{
enabled: !!id && !!name && !!artist,
refetchOnWindowFocus: false,
refetchInterval: false,
}
)
}