mirror of
https://github.com/Jellify-Music/App.git
synced 2026-02-23 04:08:48 -06:00
adding image queries and adding card component + usage
This commit is contained in:
12
api/queries/functions/images.ts
Normal file
12
api/queries/functions/images.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Api } from "@jellyfin/sdk/lib/api"
|
||||
import { ImageType } from "@jellyfin/sdk/lib/generated-client/models"
|
||||
import { getImageApi } from "@jellyfin/sdk/lib/utils/api"
|
||||
|
||||
export function fetchItemImage(api: Api, itemId: string, imageType?: ImageType) {
|
||||
|
||||
return getImageApi(api)
|
||||
.getItemImage({
|
||||
imageType: imageType ? imageType : ImageType.Primary,
|
||||
itemId
|
||||
})
|
||||
}
|
||||
9
api/queries/image.ts
Normal file
9
api/queries/image.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { QueryKeys } from "../../enums/query-keys";
|
||||
import { Api } from "@jellyfin/sdk";
|
||||
import { fetchItemImage } from "./functions/images";
|
||||
|
||||
export const useItemImage = (api: Api, itemId: string) => useQuery({
|
||||
queryKey: [QueryKeys.ItemImage, api, itemId],
|
||||
queryFn: ({ queryKey }) => fetchItemImage(queryKey[1] as Api, queryKey[2] as string)
|
||||
});
|
||||
Reference in New Issue
Block a user