use type alias ParentId

This commit is contained in:
grafixeyehero 2023-07-12 18:37:04 +03:00
parent 9cd330ef15
commit e9fb141431
2 changed files with 15 additions and 12 deletions

View file

@ -18,10 +18,11 @@ import { useQuery } from '@tanstack/react-query';
import { JellyfinApiContext, useApi } from './useApi'; import { JellyfinApiContext, useApi } from './useApi';
import { Sections, SectionsViewType } from 'types/suggestionsSections'; import { Sections, SectionsViewType } from 'types/suggestionsSections';
import { ParentId } from 'types/library';
const fetchGetItem = async ( const fetchGetItem = async (
currentApi: JellyfinApiContext, currentApi: JellyfinApiContext,
parentId: string | null | undefined, parentId: ParentId,
options?: AxiosRequestConfig options?: AxiosRequestConfig
) => { ) => {
const { api, user } = currentApi; const { api, user } = currentApi;
@ -39,7 +40,7 @@ const fetchGetItem = async (
} }
}; };
export const useGetItem = (parentId: string | null | undefined) => { export const useGetItem = (parentId: ParentId) => {
const currentApi = useApi(); const currentApi = useApi();
return useQuery({ return useQuery({
queryKey: ['Item', parentId], queryKey: ['Item', parentId],
@ -85,7 +86,7 @@ export const useGetItems = (parametersOptions: ItemsApiGetItemsRequest) => {
const fetchGetMovieRecommendations = async ( const fetchGetMovieRecommendations = async (
currentApi: JellyfinApiContext, currentApi: JellyfinApiContext,
parentId: string | null | undefined, parentId: ParentId,
options?: AxiosRequestConfig options?: AxiosRequestConfig
) => { ) => {
const { api, user } = currentApi; const { api, user } = currentApi;
@ -110,7 +111,7 @@ const fetchGetMovieRecommendations = async (
} }
}; };
export const useGetMovieRecommendations = (parentId: string | null | undefined) => { export const useGetMovieRecommendations = (parentId: ParentId) => {
const currentApi = useApi(); const currentApi = useApi();
return useQuery({ return useQuery({
queryKey: ['MovieRecommendations', parentId], queryKey: ['MovieRecommendations', parentId],
@ -123,7 +124,7 @@ export const useGetMovieRecommendations = (parentId: string | null | undefined)
const fetchGetItemsBySuggestionsType = async ( const fetchGetItemsBySuggestionsType = async (
currentApi: JellyfinApiContext, currentApi: JellyfinApiContext,
sections: Sections, sections: Sections,
parentId: string | null | undefined, parentId: ParentId,
options?: AxiosRequestConfig options?: AxiosRequestConfig
) => { ) => {
const { api, user } = currentApi; const { api, user } = currentApi;
@ -236,7 +237,7 @@ const fetchGetItemsBySuggestionsType = async (
export const useGetItemsBySectionType = ( export const useGetItemsBySectionType = (
sections: Sections, sections: Sections,
parentId: string | null | undefined parentId: ParentId
) => { ) => {
const currentApi = useApi(); const currentApi = useApi();
return useQuery({ return useQuery({
@ -255,7 +256,7 @@ export const useGetItemsBySectionType = (
const fetchGetGenres = async ( const fetchGetGenres = async (
currentApi: JellyfinApiContext, currentApi: JellyfinApiContext,
itemType: BaseItemKind, itemType: BaseItemKind,
parentId: string | null | undefined, parentId: ParentId,
options?: AxiosRequestConfig options?: AxiosRequestConfig
) => { ) => {
const { api, user } = currentApi; const { api, user } = currentApi;
@ -277,7 +278,7 @@ const fetchGetGenres = async (
} }
}; };
export const useGetGenres = (itemType: BaseItemKind, parentId: string | null | undefined) => { export const useGetGenres = (itemType: BaseItemKind, parentId: ParentId) => {
const currentApi = useApi(); const currentApi = useApi();
return useQuery({ return useQuery({
queryKey: ['Genres', parentId], queryKey: ['Genres', parentId],
@ -289,7 +290,7 @@ export const useGetGenres = (itemType: BaseItemKind, parentId: string | null | u
const fetchGetStudios = async ( const fetchGetStudios = async (
currentApi: JellyfinApiContext, currentApi: JellyfinApiContext,
parentId: string | null | undefined, parentId: ParentId,
itemType: BaseItemKind, itemType: BaseItemKind,
options?: AxiosRequestConfig options?: AxiosRequestConfig
) => { ) => {
@ -315,7 +316,7 @@ const fetchGetStudios = async (
} }
}; };
export const useGetStudios = (parentId: string | null | undefined, itemType: BaseItemKind) => { export const useGetStudios = (parentId: ParentId, itemType: BaseItemKind) => {
const currentApi = useApi(); const currentApi = useApi();
return useQuery({ return useQuery({
queryKey: ['Studios', parentId, itemType], queryKey: ['Studios', parentId, itemType],
@ -327,7 +328,7 @@ export const useGetStudios = (parentId: string | null | undefined, itemType: Bas
const fetchGetQueryFiltersLegacy = async ( const fetchGetQueryFiltersLegacy = async (
currentApi: JellyfinApiContext, currentApi: JellyfinApiContext,
parentId: string | null | undefined, parentId: ParentId,
itemType: BaseItemKind, itemType: BaseItemKind,
options?: AxiosRequestConfig options?: AxiosRequestConfig
) => { ) => {
@ -348,7 +349,7 @@ const fetchGetQueryFiltersLegacy = async (
}; };
export const useGetQueryFiltersLegacy = ( export const useGetQueryFiltersLegacy = (
parentId: string | null | undefined, parentId: ParentId,
itemType: BaseItemKind itemType: BaseItemKind
) => { ) => {
const currentApi = useApi(); const currentApi = useApi();

View file

@ -4,6 +4,8 @@ import type { SortOrder } from '@jellyfin/sdk/lib/generated-client/models/sort-o
import type { SeriesStatus } from '@jellyfin/sdk/lib/generated-client/models/series-status'; import type { SeriesStatus } from '@jellyfin/sdk/lib/generated-client/models/series-status';
import { ItemSortBy } from '@jellyfin/sdk/lib/models/api/item-sort-by'; import { ItemSortBy } from '@jellyfin/sdk/lib/models/api/item-sort-by';
export type ParentId = string | null | undefined;
export interface LibraryViewProps { export interface LibraryViewProps {
parentId: string | null; parentId: string | null;
} }