mirror of
https://github.com/Jellify-Music/App.git
synced 2026-01-05 18:40:01 -06:00
add function for retrieving artist image ig?
This commit is contained in:
@@ -3,6 +3,17 @@ import { ImageFormat, ImageType } from "@jellyfin/sdk/lib/generated-client/model
|
||||
import { getImageApi } from "@jellyfin/sdk/lib/utils/api"
|
||||
import _ from "lodash"
|
||||
|
||||
export function fetchArtistImage(api: Api, artistId: string, imageType?: ImageType) {
|
||||
return getImageApi(api).getArtistImage({
|
||||
name: "",
|
||||
imageIndex: 1,
|
||||
imageType: imageType ? imageType : ImageType.Primary
|
||||
})
|
||||
.then((response) => {
|
||||
console.log(response.data)
|
||||
return response.data;
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchItemImage(api: Api, itemId: string, imageType?: ImageType, width?: number) {
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { QueryKeys } from "../../enums/query-keys";
|
||||
import { Api } from "@jellyfin/sdk";
|
||||
import { fetchItemImage } from "./functions/images";
|
||||
import { fetchArtistImage, fetchItemImage } from "./functions/images";
|
||||
import { ImageType } from "@jellyfin/sdk/lib/generated-client/models";
|
||||
|
||||
export const useArtistImage = (api: Api, artistName: string, imageType?: ImageType) => useQuery({
|
||||
queryKey: [QueryKeys.ArtistImage, api, artistName, imageType],
|
||||
queryFn: ({ queryKey }) => fetchArtistImage(queryKey[1] as Api, queryKey[2] as string, queryKey[3] as ImageType | undefined)
|
||||
})
|
||||
|
||||
export const useItemImage = (api: Api, itemId: string, imageType?: ImageType, width?: number) => useQuery({
|
||||
queryKey: [QueryKeys.ItemImage, api, itemId, imageType, width],
|
||||
queryFn: ({ queryKey }) => fetchItemImage(queryKey[1] as Api, queryKey[2] as string, imageType, width)
|
||||
queryFn: ({ queryKey }) => fetchItemImage(queryKey[1] as Api, queryKey[2] as string, queryKey[3] as ImageType | undefined, queryKey[4] as number | undefined)
|
||||
});
|
||||
Reference in New Issue
Block a user