2022-03-13 14:40:38 +08:00
|
|
|
import { fetchArtistAlbums } from '@/api/artist'
|
|
|
|
import { ArtistApiNames } from '@/api/artist'
|
2022-03-19 17:03:29 +08:00
|
|
|
import type {
|
|
|
|
FetchArtistAlbumsParams,
|
|
|
|
FetchArtistAlbumsResponse,
|
|
|
|
} from '@/api/artist'
|
2022-03-13 14:40:38 +08:00
|
|
|
|
|
|
|
export default function useUserAlbums(params: FetchArtistAlbumsParams) {
|
|
|
|
return useQuery(
|
|
|
|
[ArtistApiNames.FETCH_ARTIST_ALBUMS, params],
|
|
|
|
async () => {
|
|
|
|
const data = await fetchArtistAlbums(params)
|
|
|
|
return data
|
|
|
|
},
|
|
|
|
{
|
|
|
|
enabled: !!params.id && params.id !== 0,
|
|
|
|
staleTime: 3600000,
|
2022-03-19 17:03:29 +08:00
|
|
|
placeholderData: (): FetchArtistAlbumsResponse =>
|
|
|
|
window.ipcRenderer.sendSync('getApiCacheSync', {
|
|
|
|
api: 'artist/album',
|
|
|
|
query: {
|
|
|
|
id: params.id,
|
|
|
|
},
|
|
|
|
}),
|
2022-03-13 14:40:38 +08:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|