2022-04-09 00:28:37 +08:00
|
|
|
import { fetchArtistAlbums } from '@/renderer/api/artist'
|
2022-04-16 21:14:03 +08:00
|
|
|
import { IpcChannels } from '@/shared/IpcChannels'
|
|
|
|
import { APIs } from '@/shared/CacheAPIs'
|
|
|
|
import {
|
2022-03-19 17:03:29 +08:00
|
|
|
FetchArtistAlbumsParams,
|
2022-04-16 21:14:03 +08:00
|
|
|
ArtistApiNames,
|
2022-03-19 17:03:29 +08:00
|
|
|
FetchArtistAlbumsResponse,
|
2022-04-16 21:14:03 +08:00
|
|
|
} from '@/shared/api/Artist'
|
2022-03-13 14:40:38 +08:00
|
|
|
|
|
|
|
export default function useUserAlbums(params: FetchArtistAlbumsParams) {
|
|
|
|
return useQuery(
|
2022-04-16 22:39:51 +08:00
|
|
|
[ArtistApiNames.FetchArtistAlbums, params],
|
2022-03-13 14:40:38 +08:00
|
|
|
async () => {
|
|
|
|
const data = await fetchArtistAlbums(params)
|
|
|
|
return data
|
|
|
|
},
|
|
|
|
{
|
|
|
|
enabled: !!params.id && params.id !== 0,
|
|
|
|
staleTime: 3600000,
|
2022-03-30 00:53:05 +08:00
|
|
|
placeholderData: (): FetchArtistAlbumsResponse =>
|
2022-04-09 00:28:37 +08:00
|
|
|
window.ipcRenderer?.sendSync(IpcChannels.GetApiCacheSync, {
|
2022-04-16 21:14:03 +08:00
|
|
|
api: APIs.ArtistAlbum,
|
2022-03-30 00:53:05 +08:00
|
|
|
query: {
|
|
|
|
id: params.id,
|
|
|
|
},
|
|
|
|
}),
|
2022-03-13 14:40:38 +08:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|