not fucking around

This commit is contained in:
Violet Caulfield
2024-11-30 10:01:07 -06:00
parent 92116227ca
commit 12f36817e3
3 changed files with 21 additions and 3 deletions
+13
View File
@@ -3,6 +3,19 @@ import { ImageFormat, ImageType } from "@jellyfin/sdk/lib/generated-client/model
import { getImageApi } from "@jellyfin/sdk/lib/utils/api"
import _ from "lodash"
export function fetchImage(api: Api, itemId: string, imageType?: ImageType) : Promise<string> {
return api.axiosInstance
.get(getImageApi(api).getItemImageUrlById(itemId, imageType))
.then((response) => {
console.log(response.data);
return convertFileToBase64(response.data);
})
}
export function fetchArtistImage(api: Api, artistId: string, imageType?: ImageType) : Promise<string> {
return new Promise(async (resolve, reject) => {
let response = await getImageApi(api).getArtistImage({
+6 -1
View File
@@ -1,9 +1,14 @@
import { useQuery } from "@tanstack/react-query";
import { QueryKeys } from "../../enums/query-keys";
import { Api } from "@jellyfin/sdk";
import { fetchArtistImage, fetchItemImage } from "./functions/images";
import { fetchArtistImage, fetchImage, fetchItemImage } from "./functions/images";
import { ImageType } from "@jellyfin/sdk/lib/generated-client/models";
export const useImage = (api: Api, itemId: string, imageType?: ImageType) => useQuery({
queryKey: [QueryKeys.ItemImage, api, itemId, imageType],
queryFn: ({ queryKey }) => fetchImage(queryKey[1] as Api, queryKey[2] as string, queryKey[3] as ImageType | undefined)
});
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)