YesPlayMusic/src/renderer/hooks/useUserPlaylists.ts

30 lines
769 B
TypeScript
Raw Normal View History

2022-03-19 17:03:29 +08:00
import type {
FetchUserPlaylistsParams,
FetchUserPlaylistsResponse,
} from '@/api/user'
2022-03-13 14:40:38 +08:00
import { UserApiNames, fetchUserPlaylists } from '@/api/user'
export default function useUserPlaylists(params: FetchUserPlaylistsParams) {
return useQuery(
[UserApiNames.FETCH_USER_PLAYLISTS, params],
async () => {
const data = await fetchUserPlaylists(params)
return data
},
{
enabled: !!(
!!params.uid &&
params.uid !== 0 &&
params.offset !== undefined
),
// placeholderData: (): FetchUserPlaylistsResponse =>
// window.ipcRenderer.sendSync('getApiCacheSync', {
// api: 'user/playlist',
// query: {
// uid: params.uid,
// },
// }),
2022-03-13 14:40:38 +08:00
}
)
}