mirror of
https://github.com/Jellify-Music/App.git
synced 2026-05-08 04:19:34 -05:00
not fucking around
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user